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

import qualified Amazonka.Core as Core
import Amazonka.IoTSiteWise.DescribeAsset
import Amazonka.IoTSiteWise.DescribeAssetModel
import Amazonka.IoTSiteWise.DescribePortal
import Amazonka.IoTSiteWise.Lens
import Amazonka.IoTSiteWise.Types
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Polls 'Amazonka.IoTSiteWise.DescribeAssetModel' every 3 seconds until a successful state is reached. An error is returned after 20 failed checks.
newAssetModelNotExists :: Core.Wait DescribeAssetModel
newAssetModelNotExists :: Wait DescribeAssetModel
newAssetModelNotExists =
  Wait :: forall a. ByteString -> Int -> Seconds -> [Acceptor a] -> Wait a
Core.Wait
    { $sel:_waitName:Wait :: ByteString
Core._waitName = ByteString
"AssetModelNotExists",
      $sel:_waitAttempts:Wait :: Int
Core._waitAttempts = Int
20,
      $sel:_waitDelay:Wait :: Seconds
Core._waitDelay = Seconds
3,
      $sel:_waitAcceptors:Wait :: [Acceptor DescribeAssetModel]
Core._waitAcceptors =
        [ ErrorCode -> Accept -> Acceptor DescribeAssetModel
forall a. ErrorCode -> Accept -> Acceptor a
Core.matchError
            ErrorCode
"ResourceNotFoundException"
            Accept
Core.AcceptSuccess
        ]
    }

-- | Polls 'Amazonka.IoTSiteWise.DescribeAsset' every 3 seconds until a successful state is reached. An error is returned after 20 failed checks.
newAssetNotExists :: Core.Wait DescribeAsset
newAssetNotExists :: Wait DescribeAsset
newAssetNotExists =
  Wait :: forall a. ByteString -> Int -> Seconds -> [Acceptor a] -> Wait a
Core.Wait
    { $sel:_waitName:Wait :: ByteString
Core._waitName = ByteString
"AssetNotExists",
      $sel:_waitAttempts:Wait :: Int
Core._waitAttempts = Int
20,
      $sel:_waitDelay:Wait :: Seconds
Core._waitDelay = Seconds
3,
      $sel:_waitAcceptors:Wait :: [Acceptor DescribeAsset]
Core._waitAcceptors =
        [ ErrorCode -> Accept -> Acceptor DescribeAsset
forall a. ErrorCode -> Accept -> Acceptor a
Core.matchError
            ErrorCode
"ResourceNotFoundException"
            Accept
Core.AcceptSuccess
        ]
    }

-- | Polls 'Amazonka.IoTSiteWise.DescribeAssetModel' every 3 seconds until a successful state is reached. An error is returned after 20 failed checks.
newAssetModelActive :: Core.Wait DescribeAssetModel
newAssetModelActive :: Wait DescribeAssetModel
newAssetModelActive =
  Wait :: forall a. ByteString -> Int -> Seconds -> [Acceptor a] -> Wait a
Core.Wait
    { $sel:_waitName:Wait :: ByteString
Core._waitName = ByteString
"AssetModelActive",
      $sel:_waitAttempts:Wait :: Int
Core._waitAttempts = Int
20,
      $sel:_waitDelay:Wait :: Seconds
Core._waitDelay = Seconds
3,
      $sel:_waitAcceptors:Wait :: [Acceptor DescribeAssetModel]
Core._waitAcceptors =
        [ CI Text
-> Accept
-> Fold (AWSResponse DescribeAssetModel) (CI Text)
-> Acceptor DescribeAssetModel
forall b a.
Eq b =>
b -> Accept -> Fold (AWSResponse a) b -> Acceptor a
Core.matchAll
            CI Text
"ACTIVE"
            Accept
Core.AcceptSuccess
            ( (AssetModelStatus -> f AssetModelStatus)
-> DescribeAssetModelResponse -> f DescribeAssetModelResponse
Lens' DescribeAssetModelResponse AssetModelStatus
describeAssetModelResponse_assetModelStatus
                ((AssetModelStatus -> f AssetModelStatus)
 -> DescribeAssetModelResponse -> f DescribeAssetModelResponse)
-> ((CI Text -> f (CI Text))
    -> AssetModelStatus -> f AssetModelStatus)
-> (CI Text -> f (CI Text))
-> DescribeAssetModelResponse
-> f DescribeAssetModelResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (AssetModelState -> f AssetModelState)
-> AssetModelStatus -> f AssetModelStatus
Lens' AssetModelStatus AssetModelState
assetModelStatus_state
                ((AssetModelState -> f AssetModelState)
 -> AssetModelStatus -> f AssetModelStatus)
-> ((CI Text -> f (CI Text))
    -> AssetModelState -> f AssetModelState)
-> (CI Text -> f (CI Text))
-> AssetModelStatus
-> f AssetModelStatus
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (AssetModelState -> CI Text)
-> (CI Text -> f (CI Text)) -> AssetModelState -> f AssetModelState
forall (p :: * -> * -> *) (f :: * -> *) s a.
(Profunctor p, Contravariant f) =>
(s -> a) -> Optic' p f s a
Lens.to AssetModelState -> CI Text
forall a. ToText a => a -> CI Text
Core.toTextCI
            ),
          CI Text
-> Accept
-> Fold (AWSResponse DescribeAssetModel) (CI Text)
-> Acceptor DescribeAssetModel
forall b a.
Eq b =>
b -> Accept -> Fold (AWSResponse a) b -> Acceptor a
Core.matchAll
            CI Text
"FAILED"
            Accept
Core.AcceptFailure
            ( (AssetModelStatus -> f AssetModelStatus)
-> DescribeAssetModelResponse -> f DescribeAssetModelResponse
Lens' DescribeAssetModelResponse AssetModelStatus
describeAssetModelResponse_assetModelStatus
                ((AssetModelStatus -> f AssetModelStatus)
 -> DescribeAssetModelResponse -> f DescribeAssetModelResponse)
-> ((CI Text -> f (CI Text))
    -> AssetModelStatus -> f AssetModelStatus)
-> (CI Text -> f (CI Text))
-> DescribeAssetModelResponse
-> f DescribeAssetModelResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (AssetModelState -> f AssetModelState)
-> AssetModelStatus -> f AssetModelStatus
Lens' AssetModelStatus AssetModelState
assetModelStatus_state
                ((AssetModelState -> f AssetModelState)
 -> AssetModelStatus -> f AssetModelStatus)
-> ((CI Text -> f (CI Text))
    -> AssetModelState -> f AssetModelState)
-> (CI Text -> f (CI Text))
-> AssetModelStatus
-> f AssetModelStatus
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (AssetModelState -> CI Text)
-> (CI Text -> f (CI Text)) -> AssetModelState -> f AssetModelState
forall (p :: * -> * -> *) (f :: * -> *) s a.
(Profunctor p, Contravariant f) =>
(s -> a) -> Optic' p f s a
Lens.to AssetModelState -> CI Text
forall a. ToText a => a -> CI Text
Core.toTextCI
            )
        ]
    }

-- | Polls 'Amazonka.IoTSiteWise.DescribePortal' every 3 seconds until a successful state is reached. An error is returned after 20 failed checks.
newPortalNotExists :: Core.Wait DescribePortal
newPortalNotExists :: Wait DescribePortal
newPortalNotExists =
  Wait :: forall a. ByteString -> Int -> Seconds -> [Acceptor a] -> Wait a
Core.Wait
    { $sel:_waitName:Wait :: ByteString
Core._waitName = ByteString
"PortalNotExists",
      $sel:_waitAttempts:Wait :: Int
Core._waitAttempts = Int
20,
      $sel:_waitDelay:Wait :: Seconds
Core._waitDelay = Seconds
3,
      $sel:_waitAcceptors:Wait :: [Acceptor DescribePortal]
Core._waitAcceptors =
        [ ErrorCode -> Accept -> Acceptor DescribePortal
forall a. ErrorCode -> Accept -> Acceptor a
Core.matchError
            ErrorCode
"ResourceNotFoundException"
            Accept
Core.AcceptSuccess
        ]
    }

-- | Polls 'Amazonka.IoTSiteWise.DescribeAsset' every 3 seconds until a successful state is reached. An error is returned after 20 failed checks.
newAssetActive :: Core.Wait DescribeAsset
newAssetActive :: Wait DescribeAsset
newAssetActive =
  Wait :: forall a. ByteString -> Int -> Seconds -> [Acceptor a] -> Wait a
Core.Wait
    { $sel:_waitName:Wait :: ByteString
Core._waitName = ByteString
"AssetActive",
      $sel:_waitAttempts:Wait :: Int
Core._waitAttempts = Int
20,
      $sel:_waitDelay:Wait :: Seconds
Core._waitDelay = Seconds
3,
      $sel:_waitAcceptors:Wait :: [Acceptor DescribeAsset]
Core._waitAcceptors =
        [ CI Text
-> Accept
-> Fold (AWSResponse DescribeAsset) (CI Text)
-> Acceptor DescribeAsset
forall b a.
Eq b =>
b -> Accept -> Fold (AWSResponse a) b -> Acceptor a
Core.matchAll
            CI Text
"ACTIVE"
            Accept
Core.AcceptSuccess
            ( (AssetStatus -> f AssetStatus)
-> DescribeAssetResponse -> f DescribeAssetResponse
Lens' DescribeAssetResponse AssetStatus
describeAssetResponse_assetStatus
                ((AssetStatus -> f AssetStatus)
 -> DescribeAssetResponse -> f DescribeAssetResponse)
-> ((CI Text -> f (CI Text)) -> AssetStatus -> f AssetStatus)
-> (CI Text -> f (CI Text))
-> DescribeAssetResponse
-> f DescribeAssetResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (AssetState -> f AssetState) -> AssetStatus -> f AssetStatus
Lens' AssetStatus AssetState
assetStatus_state
                ((AssetState -> f AssetState) -> AssetStatus -> f AssetStatus)
-> ((CI Text -> f (CI Text)) -> AssetState -> f AssetState)
-> (CI Text -> f (CI Text))
-> AssetStatus
-> f AssetStatus
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (AssetState -> CI Text)
-> (CI Text -> f (CI Text)) -> AssetState -> f AssetState
forall (p :: * -> * -> *) (f :: * -> *) s a.
(Profunctor p, Contravariant f) =>
(s -> a) -> Optic' p f s a
Lens.to AssetState -> CI Text
forall a. ToText a => a -> CI Text
Core.toTextCI
            ),
          CI Text
-> Accept
-> Fold (AWSResponse DescribeAsset) (CI Text)
-> Acceptor DescribeAsset
forall b a.
Eq b =>
b -> Accept -> Fold (AWSResponse a) b -> Acceptor a
Core.matchAll
            CI Text
"FAILED"
            Accept
Core.AcceptFailure
            ( (AssetStatus -> f AssetStatus)
-> DescribeAssetResponse -> f DescribeAssetResponse
Lens' DescribeAssetResponse AssetStatus
describeAssetResponse_assetStatus
                ((AssetStatus -> f AssetStatus)
 -> DescribeAssetResponse -> f DescribeAssetResponse)
-> ((CI Text -> f (CI Text)) -> AssetStatus -> f AssetStatus)
-> (CI Text -> f (CI Text))
-> DescribeAssetResponse
-> f DescribeAssetResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (AssetState -> f AssetState) -> AssetStatus -> f AssetStatus
Lens' AssetStatus AssetState
assetStatus_state
                ((AssetState -> f AssetState) -> AssetStatus -> f AssetStatus)
-> ((CI Text -> f (CI Text)) -> AssetState -> f AssetState)
-> (CI Text -> f (CI Text))
-> AssetStatus
-> f AssetStatus
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (AssetState -> CI Text)
-> (CI Text -> f (CI Text)) -> AssetState -> f AssetState
forall (p :: * -> * -> *) (f :: * -> *) s a.
(Profunctor p, Contravariant f) =>
(s -> a) -> Optic' p f s a
Lens.to AssetState -> CI Text
forall a. ToText a => a -> CI Text
Core.toTextCI
            )
        ]
    }

-- | Polls 'Amazonka.IoTSiteWise.DescribePortal' every 3 seconds until a successful state is reached. An error is returned after 20 failed checks.
newPortalActive :: Core.Wait DescribePortal
newPortalActive :: Wait DescribePortal
newPortalActive =
  Wait :: forall a. ByteString -> Int -> Seconds -> [Acceptor a] -> Wait a
Core.Wait
    { $sel:_waitName:Wait :: ByteString
Core._waitName = ByteString
"PortalActive",
      $sel:_waitAttempts:Wait :: Int
Core._waitAttempts = Int
20,
      $sel:_waitDelay:Wait :: Seconds
Core._waitDelay = Seconds
3,
      $sel:_waitAcceptors:Wait :: [Acceptor DescribePortal]
Core._waitAcceptors =
        [ CI Text
-> Accept
-> Fold (AWSResponse DescribePortal) (CI Text)
-> Acceptor DescribePortal
forall b a.
Eq b =>
b -> Accept -> Fold (AWSResponse a) b -> Acceptor a
Core.matchAll
            CI Text
"ACTIVE"
            Accept
Core.AcceptSuccess
            ( (PortalStatus -> f PortalStatus)
-> DescribePortalResponse -> f DescribePortalResponse
Lens' DescribePortalResponse PortalStatus
describePortalResponse_portalStatus
                ((PortalStatus -> f PortalStatus)
 -> DescribePortalResponse -> f DescribePortalResponse)
-> ((CI Text -> f (CI Text)) -> PortalStatus -> f PortalStatus)
-> (CI Text -> f (CI Text))
-> DescribePortalResponse
-> f DescribePortalResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (PortalState -> f PortalState) -> PortalStatus -> f PortalStatus
Lens' PortalStatus PortalState
portalStatus_state
                ((PortalState -> f PortalState) -> PortalStatus -> f PortalStatus)
-> ((CI Text -> f (CI Text)) -> PortalState -> f PortalState)
-> (CI Text -> f (CI Text))
-> PortalStatus
-> f PortalStatus
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (PortalState -> CI Text)
-> (CI Text -> f (CI Text)) -> PortalState -> f PortalState
forall (p :: * -> * -> *) (f :: * -> *) s a.
(Profunctor p, Contravariant f) =>
(s -> a) -> Optic' p f s a
Lens.to PortalState -> CI Text
forall a. ToText a => a -> CI Text
Core.toTextCI
            )
        ]
    }