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

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import Amazonka.Rekognition.DescribeProjectVersions
import Amazonka.Rekognition.Lens
import Amazonka.Rekognition.Types

-- | Polls 'Amazonka.Rekognition.DescribeProjectVersions' every 30 seconds until a successful state is reached. An error is returned after 40 failed checks.
newProjectVersionRunning :: Core.Wait DescribeProjectVersions
newProjectVersionRunning :: Wait DescribeProjectVersions
newProjectVersionRunning =
  Wait :: forall a. ByteString -> Int -> Seconds -> [Acceptor a] -> Wait a
Core.Wait
    { $sel:_waitName:Wait :: ByteString
Core._waitName = ByteString
"ProjectVersionRunning",
      $sel:_waitAttempts:Wait :: Int
Core._waitAttempts = Int
40,
      $sel:_waitDelay:Wait :: Seconds
Core._waitDelay = Seconds
30,
      $sel:_waitAcceptors:Wait :: [Acceptor DescribeProjectVersions]
Core._waitAcceptors =
        [ CI Text
-> Accept
-> Fold (AWSResponse DescribeProjectVersions) (CI Text)
-> Acceptor DescribeProjectVersions
forall b a.
Eq b =>
b -> Accept -> Fold (AWSResponse a) b -> Acceptor a
Core.matchAll
            CI Text
"RUNNING"
            Accept
Core.AcceptSuccess
            ( (DescribeProjectVersionsResponse -> [ProjectVersionDescription])
-> Fold DescribeProjectVersionsResponse ProjectVersionDescription
forall (f :: * -> *) s a. Foldable f => (s -> f a) -> Fold s a
Lens.folding
                ( Getting
  [ProjectVersionDescription]
  DescribeProjectVersionsResponse
  [ProjectVersionDescription]
-> DescribeProjectVersionsResponse -> [ProjectVersionDescription]
forall r s. Getting [r] s [r] -> s -> [r]
Lens.concatOf
                    ( (Maybe [ProjectVersionDescription]
 -> Const
      [ProjectVersionDescription] (Maybe [ProjectVersionDescription]))
-> DescribeProjectVersionsResponse
-> Const
     [ProjectVersionDescription] DescribeProjectVersionsResponse
Lens'
  DescribeProjectVersionsResponse (Maybe [ProjectVersionDescription])
describeProjectVersionsResponse_projectVersionDescriptions
                        ((Maybe [ProjectVersionDescription]
  -> Const
       [ProjectVersionDescription] (Maybe [ProjectVersionDescription]))
 -> DescribeProjectVersionsResponse
 -> Const
      [ProjectVersionDescription] DescribeProjectVersionsResponse)
-> (([ProjectVersionDescription]
     -> Const [ProjectVersionDescription] [ProjectVersionDescription])
    -> Maybe [ProjectVersionDescription]
    -> Const
         [ProjectVersionDescription] (Maybe [ProjectVersionDescription]))
-> Getting
     [ProjectVersionDescription]
     DescribeProjectVersionsResponse
     [ProjectVersionDescription]
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. ([ProjectVersionDescription]
 -> Const [ProjectVersionDescription] [ProjectVersionDescription])
-> Maybe [ProjectVersionDescription]
-> Const
     [ProjectVersionDescription] (Maybe [ProjectVersionDescription])
forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just
                    )
                )
                ((ProjectVersionDescription -> f ProjectVersionDescription)
 -> DescribeProjectVersionsResponse
 -> f DescribeProjectVersionsResponse)
-> ((CI Text -> f (CI Text))
    -> ProjectVersionDescription -> f ProjectVersionDescription)
-> (CI Text -> f (CI Text))
-> DescribeProjectVersionsResponse
-> f DescribeProjectVersionsResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (Maybe ProjectVersionStatus -> f (Maybe ProjectVersionStatus))
-> ProjectVersionDescription -> f ProjectVersionDescription
Lens' ProjectVersionDescription (Maybe ProjectVersionStatus)
projectVersionDescription_status
                ((Maybe ProjectVersionStatus -> f (Maybe ProjectVersionStatus))
 -> ProjectVersionDescription -> f ProjectVersionDescription)
-> ((CI Text -> f (CI Text))
    -> Maybe ProjectVersionStatus -> f (Maybe ProjectVersionStatus))
-> (CI Text -> f (CI Text))
-> ProjectVersionDescription
-> f ProjectVersionDescription
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (ProjectVersionStatus -> f ProjectVersionStatus)
-> Maybe ProjectVersionStatus -> f (Maybe ProjectVersionStatus)
forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just
                ((ProjectVersionStatus -> f ProjectVersionStatus)
 -> Maybe ProjectVersionStatus -> f (Maybe ProjectVersionStatus))
-> ((CI Text -> f (CI Text))
    -> ProjectVersionStatus -> f ProjectVersionStatus)
-> (CI Text -> f (CI Text))
-> Maybe ProjectVersionStatus
-> f (Maybe ProjectVersionStatus)
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (ProjectVersionStatus -> CI Text)
-> (CI Text -> f (CI Text))
-> ProjectVersionStatus
-> f ProjectVersionStatus
forall (p :: * -> * -> *) (f :: * -> *) s a.
(Profunctor p, Contravariant f) =>
(s -> a) -> Optic' p f s a
Lens.to ProjectVersionStatus -> CI Text
forall a. ToText a => a -> CI Text
Core.toTextCI
            ),
          CI Text
-> Accept
-> Fold (AWSResponse DescribeProjectVersions) (CI Text)
-> Acceptor DescribeProjectVersions
forall b a.
Eq b =>
b -> Accept -> Fold (AWSResponse a) b -> Acceptor a
Core.matchAny
            CI Text
"FAILED"
            Accept
Core.AcceptFailure
            ( (DescribeProjectVersionsResponse -> [ProjectVersionDescription])
-> Fold DescribeProjectVersionsResponse ProjectVersionDescription
forall (f :: * -> *) s a. Foldable f => (s -> f a) -> Fold s a
Lens.folding
                ( Getting
  [ProjectVersionDescription]
  DescribeProjectVersionsResponse
  [ProjectVersionDescription]
-> DescribeProjectVersionsResponse -> [ProjectVersionDescription]
forall r s. Getting [r] s [r] -> s -> [r]
Lens.concatOf
                    ( (Maybe [ProjectVersionDescription]
 -> Const
      [ProjectVersionDescription] (Maybe [ProjectVersionDescription]))
-> DescribeProjectVersionsResponse
-> Const
     [ProjectVersionDescription] DescribeProjectVersionsResponse
Lens'
  DescribeProjectVersionsResponse (Maybe [ProjectVersionDescription])
describeProjectVersionsResponse_projectVersionDescriptions
                        ((Maybe [ProjectVersionDescription]
  -> Const
       [ProjectVersionDescription] (Maybe [ProjectVersionDescription]))
 -> DescribeProjectVersionsResponse
 -> Const
      [ProjectVersionDescription] DescribeProjectVersionsResponse)
-> (([ProjectVersionDescription]
     -> Const [ProjectVersionDescription] [ProjectVersionDescription])
    -> Maybe [ProjectVersionDescription]
    -> Const
         [ProjectVersionDescription] (Maybe [ProjectVersionDescription]))
-> Getting
     [ProjectVersionDescription]
     DescribeProjectVersionsResponse
     [ProjectVersionDescription]
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. ([ProjectVersionDescription]
 -> Const [ProjectVersionDescription] [ProjectVersionDescription])
-> Maybe [ProjectVersionDescription]
-> Const
     [ProjectVersionDescription] (Maybe [ProjectVersionDescription])
forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just
                    )
                )
                ((ProjectVersionDescription -> f ProjectVersionDescription)
 -> DescribeProjectVersionsResponse
 -> f DescribeProjectVersionsResponse)
-> ((CI Text -> f (CI Text))
    -> ProjectVersionDescription -> f ProjectVersionDescription)
-> (CI Text -> f (CI Text))
-> DescribeProjectVersionsResponse
-> f DescribeProjectVersionsResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (Maybe ProjectVersionStatus -> f (Maybe ProjectVersionStatus))
-> ProjectVersionDescription -> f ProjectVersionDescription
Lens' ProjectVersionDescription (Maybe ProjectVersionStatus)
projectVersionDescription_status
                ((Maybe ProjectVersionStatus -> f (Maybe ProjectVersionStatus))
 -> ProjectVersionDescription -> f ProjectVersionDescription)
-> ((CI Text -> f (CI Text))
    -> Maybe ProjectVersionStatus -> f (Maybe ProjectVersionStatus))
-> (CI Text -> f (CI Text))
-> ProjectVersionDescription
-> f ProjectVersionDescription
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (ProjectVersionStatus -> f ProjectVersionStatus)
-> Maybe ProjectVersionStatus -> f (Maybe ProjectVersionStatus)
forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just
                ((ProjectVersionStatus -> f ProjectVersionStatus)
 -> Maybe ProjectVersionStatus -> f (Maybe ProjectVersionStatus))
-> ((CI Text -> f (CI Text))
    -> ProjectVersionStatus -> f ProjectVersionStatus)
-> (CI Text -> f (CI Text))
-> Maybe ProjectVersionStatus
-> f (Maybe ProjectVersionStatus)
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (ProjectVersionStatus -> CI Text)
-> (CI Text -> f (CI Text))
-> ProjectVersionStatus
-> f ProjectVersionStatus
forall (p :: * -> * -> *) (f :: * -> *) s a.
(Profunctor p, Contravariant f) =>
(s -> a) -> Optic' p f s a
Lens.to ProjectVersionStatus -> CI Text
forall a. ToText a => a -> CI Text
Core.toTextCI
            )
        ]
    }

-- | Polls 'Amazonka.Rekognition.DescribeProjectVersions' every 120 seconds until a successful state is reached. An error is returned after 360 failed checks.
newProjectVersionTrainingCompleted :: Core.Wait DescribeProjectVersions
newProjectVersionTrainingCompleted :: Wait DescribeProjectVersions
newProjectVersionTrainingCompleted =
  Wait :: forall a. ByteString -> Int -> Seconds -> [Acceptor a] -> Wait a
Core.Wait
    { $sel:_waitName:Wait :: ByteString
Core._waitName =
        ByteString
"ProjectVersionTrainingCompleted",
      $sel:_waitAttempts:Wait :: Int
Core._waitAttempts = Int
360,
      $sel:_waitDelay:Wait :: Seconds
Core._waitDelay = Seconds
120,
      $sel:_waitAcceptors:Wait :: [Acceptor DescribeProjectVersions]
Core._waitAcceptors =
        [ CI Text
-> Accept
-> Fold (AWSResponse DescribeProjectVersions) (CI Text)
-> Acceptor DescribeProjectVersions
forall b a.
Eq b =>
b -> Accept -> Fold (AWSResponse a) b -> Acceptor a
Core.matchAll
            CI Text
"TRAINING_COMPLETED"
            Accept
Core.AcceptSuccess
            ( (DescribeProjectVersionsResponse -> [ProjectVersionDescription])
-> Fold DescribeProjectVersionsResponse ProjectVersionDescription
forall (f :: * -> *) s a. Foldable f => (s -> f a) -> Fold s a
Lens.folding
                ( Getting
  [ProjectVersionDescription]
  DescribeProjectVersionsResponse
  [ProjectVersionDescription]
-> DescribeProjectVersionsResponse -> [ProjectVersionDescription]
forall r s. Getting [r] s [r] -> s -> [r]
Lens.concatOf
                    ( (Maybe [ProjectVersionDescription]
 -> Const
      [ProjectVersionDescription] (Maybe [ProjectVersionDescription]))
-> DescribeProjectVersionsResponse
-> Const
     [ProjectVersionDescription] DescribeProjectVersionsResponse
Lens'
  DescribeProjectVersionsResponse (Maybe [ProjectVersionDescription])
describeProjectVersionsResponse_projectVersionDescriptions
                        ((Maybe [ProjectVersionDescription]
  -> Const
       [ProjectVersionDescription] (Maybe [ProjectVersionDescription]))
 -> DescribeProjectVersionsResponse
 -> Const
      [ProjectVersionDescription] DescribeProjectVersionsResponse)
-> (([ProjectVersionDescription]
     -> Const [ProjectVersionDescription] [ProjectVersionDescription])
    -> Maybe [ProjectVersionDescription]
    -> Const
         [ProjectVersionDescription] (Maybe [ProjectVersionDescription]))
-> Getting
     [ProjectVersionDescription]
     DescribeProjectVersionsResponse
     [ProjectVersionDescription]
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. ([ProjectVersionDescription]
 -> Const [ProjectVersionDescription] [ProjectVersionDescription])
-> Maybe [ProjectVersionDescription]
-> Const
     [ProjectVersionDescription] (Maybe [ProjectVersionDescription])
forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just
                    )
                )
                ((ProjectVersionDescription -> f ProjectVersionDescription)
 -> DescribeProjectVersionsResponse
 -> f DescribeProjectVersionsResponse)
-> ((CI Text -> f (CI Text))
    -> ProjectVersionDescription -> f ProjectVersionDescription)
-> (CI Text -> f (CI Text))
-> DescribeProjectVersionsResponse
-> f DescribeProjectVersionsResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (Maybe ProjectVersionStatus -> f (Maybe ProjectVersionStatus))
-> ProjectVersionDescription -> f ProjectVersionDescription
Lens' ProjectVersionDescription (Maybe ProjectVersionStatus)
projectVersionDescription_status
                ((Maybe ProjectVersionStatus -> f (Maybe ProjectVersionStatus))
 -> ProjectVersionDescription -> f ProjectVersionDescription)
-> ((CI Text -> f (CI Text))
    -> Maybe ProjectVersionStatus -> f (Maybe ProjectVersionStatus))
-> (CI Text -> f (CI Text))
-> ProjectVersionDescription
-> f ProjectVersionDescription
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (ProjectVersionStatus -> f ProjectVersionStatus)
-> Maybe ProjectVersionStatus -> f (Maybe ProjectVersionStatus)
forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just
                ((ProjectVersionStatus -> f ProjectVersionStatus)
 -> Maybe ProjectVersionStatus -> f (Maybe ProjectVersionStatus))
-> ((CI Text -> f (CI Text))
    -> ProjectVersionStatus -> f ProjectVersionStatus)
-> (CI Text -> f (CI Text))
-> Maybe ProjectVersionStatus
-> f (Maybe ProjectVersionStatus)
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (ProjectVersionStatus -> CI Text)
-> (CI Text -> f (CI Text))
-> ProjectVersionStatus
-> f ProjectVersionStatus
forall (p :: * -> * -> *) (f :: * -> *) s a.
(Profunctor p, Contravariant f) =>
(s -> a) -> Optic' p f s a
Lens.to ProjectVersionStatus -> CI Text
forall a. ToText a => a -> CI Text
Core.toTextCI
            ),
          CI Text
-> Accept
-> Fold (AWSResponse DescribeProjectVersions) (CI Text)
-> Acceptor DescribeProjectVersions
forall b a.
Eq b =>
b -> Accept -> Fold (AWSResponse a) b -> Acceptor a
Core.matchAny
            CI Text
"TRAINING_FAILED"
            Accept
Core.AcceptFailure
            ( (DescribeProjectVersionsResponse -> [ProjectVersionDescription])
-> Fold DescribeProjectVersionsResponse ProjectVersionDescription
forall (f :: * -> *) s a. Foldable f => (s -> f a) -> Fold s a
Lens.folding
                ( Getting
  [ProjectVersionDescription]
  DescribeProjectVersionsResponse
  [ProjectVersionDescription]
-> DescribeProjectVersionsResponse -> [ProjectVersionDescription]
forall r s. Getting [r] s [r] -> s -> [r]
Lens.concatOf
                    ( (Maybe [ProjectVersionDescription]
 -> Const
      [ProjectVersionDescription] (Maybe [ProjectVersionDescription]))
-> DescribeProjectVersionsResponse
-> Const
     [ProjectVersionDescription] DescribeProjectVersionsResponse
Lens'
  DescribeProjectVersionsResponse (Maybe [ProjectVersionDescription])
describeProjectVersionsResponse_projectVersionDescriptions
                        ((Maybe [ProjectVersionDescription]
  -> Const
       [ProjectVersionDescription] (Maybe [ProjectVersionDescription]))
 -> DescribeProjectVersionsResponse
 -> Const
      [ProjectVersionDescription] DescribeProjectVersionsResponse)
-> (([ProjectVersionDescription]
     -> Const [ProjectVersionDescription] [ProjectVersionDescription])
    -> Maybe [ProjectVersionDescription]
    -> Const
         [ProjectVersionDescription] (Maybe [ProjectVersionDescription]))
-> Getting
     [ProjectVersionDescription]
     DescribeProjectVersionsResponse
     [ProjectVersionDescription]
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. ([ProjectVersionDescription]
 -> Const [ProjectVersionDescription] [ProjectVersionDescription])
-> Maybe [ProjectVersionDescription]
-> Const
     [ProjectVersionDescription] (Maybe [ProjectVersionDescription])
forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just
                    )
                )
                ((ProjectVersionDescription -> f ProjectVersionDescription)
 -> DescribeProjectVersionsResponse
 -> f DescribeProjectVersionsResponse)
-> ((CI Text -> f (CI Text))
    -> ProjectVersionDescription -> f ProjectVersionDescription)
-> (CI Text -> f (CI Text))
-> DescribeProjectVersionsResponse
-> f DescribeProjectVersionsResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (Maybe ProjectVersionStatus -> f (Maybe ProjectVersionStatus))
-> ProjectVersionDescription -> f ProjectVersionDescription
Lens' ProjectVersionDescription (Maybe ProjectVersionStatus)
projectVersionDescription_status
                ((Maybe ProjectVersionStatus -> f (Maybe ProjectVersionStatus))
 -> ProjectVersionDescription -> f ProjectVersionDescription)
-> ((CI Text -> f (CI Text))
    -> Maybe ProjectVersionStatus -> f (Maybe ProjectVersionStatus))
-> (CI Text -> f (CI Text))
-> ProjectVersionDescription
-> f ProjectVersionDescription
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (ProjectVersionStatus -> f ProjectVersionStatus)
-> Maybe ProjectVersionStatus -> f (Maybe ProjectVersionStatus)
forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just
                ((ProjectVersionStatus -> f ProjectVersionStatus)
 -> Maybe ProjectVersionStatus -> f (Maybe ProjectVersionStatus))
-> ((CI Text -> f (CI Text))
    -> ProjectVersionStatus -> f ProjectVersionStatus)
-> (CI Text -> f (CI Text))
-> Maybe ProjectVersionStatus
-> f (Maybe ProjectVersionStatus)
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (ProjectVersionStatus -> CI Text)
-> (CI Text -> f (CI Text))
-> ProjectVersionStatus
-> f ProjectVersionStatus
forall (p :: * -> * -> *) (f :: * -> *) s a.
(Profunctor p, Contravariant f) =>
(s -> a) -> Optic' p f s a
Lens.to ProjectVersionStatus -> CI Text
forall a. ToText a => a -> CI Text
Core.toTextCI
            )
        ]
    }