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

import Amazonka.CodeGuruReviewer.DescribeCodeReview
import Amazonka.CodeGuruReviewer.DescribeRepositoryAssociation
import Amazonka.CodeGuruReviewer.Lens
import Amazonka.CodeGuruReviewer.Types
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Polls 'Amazonka.CodeGuruReviewer.DescribeCodeReview' every 10 seconds until a successful state is reached. An error is returned after 60 failed checks.
newCodeReviewCompleted :: Core.Wait DescribeCodeReview
newCodeReviewCompleted :: Wait DescribeCodeReview
newCodeReviewCompleted =
  Wait :: forall a. ByteString -> Int -> Seconds -> [Acceptor a] -> Wait a
Core.Wait
    { $sel:_waitName:Wait :: ByteString
Core._waitName = ByteString
"CodeReviewCompleted",
      $sel:_waitAttempts:Wait :: Int
Core._waitAttempts = Int
60,
      $sel:_waitDelay:Wait :: Seconds
Core._waitDelay = Seconds
10,
      $sel:_waitAcceptors:Wait :: [Acceptor DescribeCodeReview]
Core._waitAcceptors =
        [ CI Text
-> Accept
-> Fold (AWSResponse DescribeCodeReview) (CI Text)
-> Acceptor DescribeCodeReview
forall b a.
Eq b =>
b -> Accept -> Fold (AWSResponse a) b -> Acceptor a
Core.matchAll
            CI Text
"Completed"
            Accept
Core.AcceptSuccess
            ( (Maybe CodeReview -> f (Maybe CodeReview))
-> DescribeCodeReviewResponse -> f DescribeCodeReviewResponse
Lens' DescribeCodeReviewResponse (Maybe CodeReview)
describeCodeReviewResponse_codeReview
                ((Maybe CodeReview -> f (Maybe CodeReview))
 -> DescribeCodeReviewResponse -> f DescribeCodeReviewResponse)
-> ((CI Text -> f (CI Text))
    -> Maybe CodeReview -> f (Maybe CodeReview))
-> (CI Text -> f (CI Text))
-> DescribeCodeReviewResponse
-> f DescribeCodeReviewResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (CodeReview -> f CodeReview)
-> Maybe CodeReview -> f (Maybe CodeReview)
forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just
                ((CodeReview -> f CodeReview)
 -> Maybe CodeReview -> f (Maybe CodeReview))
-> ((CI Text -> f (CI Text)) -> CodeReview -> f CodeReview)
-> (CI Text -> f (CI Text))
-> Maybe CodeReview
-> f (Maybe CodeReview)
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (Maybe JobState -> f (Maybe JobState))
-> CodeReview -> f CodeReview
Lens' CodeReview (Maybe JobState)
codeReview_state
                ((Maybe JobState -> f (Maybe JobState))
 -> CodeReview -> f CodeReview)
-> ((CI Text -> f (CI Text))
    -> Maybe JobState -> f (Maybe JobState))
-> (CI Text -> f (CI Text))
-> CodeReview
-> f CodeReview
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (JobState -> f JobState) -> Maybe JobState -> f (Maybe JobState)
forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just
                ((JobState -> f JobState) -> Maybe JobState -> f (Maybe JobState))
-> ((CI Text -> f (CI Text)) -> JobState -> f JobState)
-> (CI Text -> f (CI Text))
-> Maybe JobState
-> f (Maybe JobState)
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (JobState -> CI Text)
-> (CI Text -> f (CI Text)) -> JobState -> f JobState
forall (p :: * -> * -> *) (f :: * -> *) s a.
(Profunctor p, Contravariant f) =>
(s -> a) -> Optic' p f s a
Lens.to JobState -> CI Text
forall a. ToText a => a -> CI Text
Core.toTextCI
            ),
          CI Text
-> Accept
-> Fold (AWSResponse DescribeCodeReview) (CI Text)
-> Acceptor DescribeCodeReview
forall b a.
Eq b =>
b -> Accept -> Fold (AWSResponse a) b -> Acceptor a
Core.matchAll
            CI Text
"Pending"
            Accept
Core.AcceptRetry
            ( (Maybe CodeReview -> f (Maybe CodeReview))
-> DescribeCodeReviewResponse -> f DescribeCodeReviewResponse
Lens' DescribeCodeReviewResponse (Maybe CodeReview)
describeCodeReviewResponse_codeReview
                ((Maybe CodeReview -> f (Maybe CodeReview))
 -> DescribeCodeReviewResponse -> f DescribeCodeReviewResponse)
-> ((CI Text -> f (CI Text))
    -> Maybe CodeReview -> f (Maybe CodeReview))
-> (CI Text -> f (CI Text))
-> DescribeCodeReviewResponse
-> f DescribeCodeReviewResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (CodeReview -> f CodeReview)
-> Maybe CodeReview -> f (Maybe CodeReview)
forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just
                ((CodeReview -> f CodeReview)
 -> Maybe CodeReview -> f (Maybe CodeReview))
-> ((CI Text -> f (CI Text)) -> CodeReview -> f CodeReview)
-> (CI Text -> f (CI Text))
-> Maybe CodeReview
-> f (Maybe CodeReview)
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (Maybe JobState -> f (Maybe JobState))
-> CodeReview -> f CodeReview
Lens' CodeReview (Maybe JobState)
codeReview_state
                ((Maybe JobState -> f (Maybe JobState))
 -> CodeReview -> f CodeReview)
-> ((CI Text -> f (CI Text))
    -> Maybe JobState -> f (Maybe JobState))
-> (CI Text -> f (CI Text))
-> CodeReview
-> f CodeReview
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (JobState -> f JobState) -> Maybe JobState -> f (Maybe JobState)
forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just
                ((JobState -> f JobState) -> Maybe JobState -> f (Maybe JobState))
-> ((CI Text -> f (CI Text)) -> JobState -> f JobState)
-> (CI Text -> f (CI Text))
-> Maybe JobState
-> f (Maybe JobState)
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (JobState -> CI Text)
-> (CI Text -> f (CI Text)) -> JobState -> f JobState
forall (p :: * -> * -> *) (f :: * -> *) s a.
(Profunctor p, Contravariant f) =>
(s -> a) -> Optic' p f s a
Lens.to JobState -> CI Text
forall a. ToText a => a -> CI Text
Core.toTextCI
            )
        ]
    }

-- | Polls 'Amazonka.CodeGuruReviewer.DescribeRepositoryAssociation' every 10 seconds until a successful state is reached. An error is returned after 20 failed checks.
newRepositoryAssociationSucceeded :: Core.Wait DescribeRepositoryAssociation
newRepositoryAssociationSucceeded :: Wait DescribeRepositoryAssociation
newRepositoryAssociationSucceeded =
  Wait :: forall a. ByteString -> Int -> Seconds -> [Acceptor a] -> Wait a
Core.Wait
    { $sel:_waitName:Wait :: ByteString
Core._waitName =
        ByteString
"RepositoryAssociationSucceeded",
      $sel:_waitAttempts:Wait :: Int
Core._waitAttempts = Int
20,
      $sel:_waitDelay:Wait :: Seconds
Core._waitDelay = Seconds
10,
      $sel:_waitAcceptors:Wait :: [Acceptor DescribeRepositoryAssociation]
Core._waitAcceptors =
        [ CI Text
-> Accept
-> Fold (AWSResponse DescribeRepositoryAssociation) (CI Text)
-> Acceptor DescribeRepositoryAssociation
forall b a.
Eq b =>
b -> Accept -> Fold (AWSResponse a) b -> Acceptor a
Core.matchAll
            CI Text
"Associated"
            Accept
Core.AcceptSuccess
            ( (Maybe RepositoryAssociation -> f (Maybe RepositoryAssociation))
-> DescribeRepositoryAssociationResponse
-> f DescribeRepositoryAssociationResponse
Lens'
  DescribeRepositoryAssociationResponse (Maybe RepositoryAssociation)
describeRepositoryAssociationResponse_repositoryAssociation
                ((Maybe RepositoryAssociation -> f (Maybe RepositoryAssociation))
 -> DescribeRepositoryAssociationResponse
 -> f DescribeRepositoryAssociationResponse)
-> ((CI Text -> f (CI Text))
    -> Maybe RepositoryAssociation -> f (Maybe RepositoryAssociation))
-> (CI Text -> f (CI Text))
-> DescribeRepositoryAssociationResponse
-> f DescribeRepositoryAssociationResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (RepositoryAssociation -> f RepositoryAssociation)
-> Maybe RepositoryAssociation -> f (Maybe RepositoryAssociation)
forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just
                ((RepositoryAssociation -> f RepositoryAssociation)
 -> Maybe RepositoryAssociation -> f (Maybe RepositoryAssociation))
-> ((CI Text -> f (CI Text))
    -> RepositoryAssociation -> f RepositoryAssociation)
-> (CI Text -> f (CI Text))
-> Maybe RepositoryAssociation
-> f (Maybe RepositoryAssociation)
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (Maybe RepositoryAssociationState
 -> f (Maybe RepositoryAssociationState))
-> RepositoryAssociation -> f RepositoryAssociation
Lens' RepositoryAssociation (Maybe RepositoryAssociationState)
repositoryAssociation_state
                ((Maybe RepositoryAssociationState
  -> f (Maybe RepositoryAssociationState))
 -> RepositoryAssociation -> f RepositoryAssociation)
-> ((CI Text -> f (CI Text))
    -> Maybe RepositoryAssociationState
    -> f (Maybe RepositoryAssociationState))
-> (CI Text -> f (CI Text))
-> RepositoryAssociation
-> f RepositoryAssociation
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (RepositoryAssociationState -> f RepositoryAssociationState)
-> Maybe RepositoryAssociationState
-> f (Maybe RepositoryAssociationState)
forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just
                ((RepositoryAssociationState -> f RepositoryAssociationState)
 -> Maybe RepositoryAssociationState
 -> f (Maybe RepositoryAssociationState))
-> ((CI Text -> f (CI Text))
    -> RepositoryAssociationState -> f RepositoryAssociationState)
-> (CI Text -> f (CI Text))
-> Maybe RepositoryAssociationState
-> f (Maybe RepositoryAssociationState)
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (RepositoryAssociationState -> CI Text)
-> (CI Text -> f (CI Text))
-> RepositoryAssociationState
-> f RepositoryAssociationState
forall (p :: * -> * -> *) (f :: * -> *) s a.
(Profunctor p, Contravariant f) =>
(s -> a) -> Optic' p f s a
Lens.to RepositoryAssociationState -> CI Text
forall a. ToText a => a -> CI Text
Core.toTextCI
            ),
          CI Text
-> Accept
-> Fold (AWSResponse DescribeRepositoryAssociation) (CI Text)
-> Acceptor DescribeRepositoryAssociation
forall b a.
Eq b =>
b -> Accept -> Fold (AWSResponse a) b -> Acceptor a
Core.matchAll
            CI Text
"Associating"
            Accept
Core.AcceptRetry
            ( (Maybe RepositoryAssociation -> f (Maybe RepositoryAssociation))
-> DescribeRepositoryAssociationResponse
-> f DescribeRepositoryAssociationResponse
Lens'
  DescribeRepositoryAssociationResponse (Maybe RepositoryAssociation)
describeRepositoryAssociationResponse_repositoryAssociation
                ((Maybe RepositoryAssociation -> f (Maybe RepositoryAssociation))
 -> DescribeRepositoryAssociationResponse
 -> f DescribeRepositoryAssociationResponse)
-> ((CI Text -> f (CI Text))
    -> Maybe RepositoryAssociation -> f (Maybe RepositoryAssociation))
-> (CI Text -> f (CI Text))
-> DescribeRepositoryAssociationResponse
-> f DescribeRepositoryAssociationResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (RepositoryAssociation -> f RepositoryAssociation)
-> Maybe RepositoryAssociation -> f (Maybe RepositoryAssociation)
forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just
                ((RepositoryAssociation -> f RepositoryAssociation)
 -> Maybe RepositoryAssociation -> f (Maybe RepositoryAssociation))
-> ((CI Text -> f (CI Text))
    -> RepositoryAssociation -> f RepositoryAssociation)
-> (CI Text -> f (CI Text))
-> Maybe RepositoryAssociation
-> f (Maybe RepositoryAssociation)
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (Maybe RepositoryAssociationState
 -> f (Maybe RepositoryAssociationState))
-> RepositoryAssociation -> f RepositoryAssociation
Lens' RepositoryAssociation (Maybe RepositoryAssociationState)
repositoryAssociation_state
                ((Maybe RepositoryAssociationState
  -> f (Maybe RepositoryAssociationState))
 -> RepositoryAssociation -> f RepositoryAssociation)
-> ((CI Text -> f (CI Text))
    -> Maybe RepositoryAssociationState
    -> f (Maybe RepositoryAssociationState))
-> (CI Text -> f (CI Text))
-> RepositoryAssociation
-> f RepositoryAssociation
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (RepositoryAssociationState -> f RepositoryAssociationState)
-> Maybe RepositoryAssociationState
-> f (Maybe RepositoryAssociationState)
forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just
                ((RepositoryAssociationState -> f RepositoryAssociationState)
 -> Maybe RepositoryAssociationState
 -> f (Maybe RepositoryAssociationState))
-> ((CI Text -> f (CI Text))
    -> RepositoryAssociationState -> f RepositoryAssociationState)
-> (CI Text -> f (CI Text))
-> Maybe RepositoryAssociationState
-> f (Maybe RepositoryAssociationState)
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (RepositoryAssociationState -> CI Text)
-> (CI Text -> f (CI Text))
-> RepositoryAssociationState
-> f RepositoryAssociationState
forall (p :: * -> * -> *) (f :: * -> *) s a.
(Profunctor p, Contravariant f) =>
(s -> a) -> Optic' p f s a
Lens.to RepositoryAssociationState -> CI Text
forall a. ToText a => a -> CI Text
Core.toTextCI
            )
        ]
    }