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

import qualified Amazonka.Core as Core
import Amazonka.ECR.DescribeImageScanFindings
import Amazonka.ECR.GetLifecyclePolicyPreview
import Amazonka.ECR.Lens
import Amazonka.ECR.Types
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Polls 'Amazonka.ECR.GetLifecyclePolicyPreview' every 5 seconds until a successful state is reached. An error is returned after 20 failed checks.
newLifecyclePolicyPreviewComplete :: Core.Wait GetLifecyclePolicyPreview
newLifecyclePolicyPreviewComplete :: Wait GetLifecyclePolicyPreview
newLifecyclePolicyPreviewComplete =
  Wait :: forall a. ByteString -> Int -> Seconds -> [Acceptor a] -> Wait a
Core.Wait
    { $sel:_waitName:Wait :: ByteString
Core._waitName =
        ByteString
"LifecyclePolicyPreviewComplete",
      $sel:_waitAttempts:Wait :: Int
Core._waitAttempts = Int
20,
      $sel:_waitDelay:Wait :: Seconds
Core._waitDelay = Seconds
5,
      $sel:_waitAcceptors:Wait :: [Acceptor GetLifecyclePolicyPreview]
Core._waitAcceptors =
        [ CI Text
-> Accept
-> Fold (AWSResponse GetLifecyclePolicyPreview) (CI Text)
-> Acceptor GetLifecyclePolicyPreview
forall b a.
Eq b =>
b -> Accept -> Fold (AWSResponse a) b -> Acceptor a
Core.matchAll
            CI Text
"COMPLETE"
            Accept
Core.AcceptSuccess
            ( (Maybe LifecyclePolicyPreviewStatus
 -> f (Maybe LifecyclePolicyPreviewStatus))
-> GetLifecyclePolicyPreviewResponse
-> f GetLifecyclePolicyPreviewResponse
Lens'
  GetLifecyclePolicyPreviewResponse
  (Maybe LifecyclePolicyPreviewStatus)
getLifecyclePolicyPreviewResponse_status
                ((Maybe LifecyclePolicyPreviewStatus
  -> f (Maybe LifecyclePolicyPreviewStatus))
 -> GetLifecyclePolicyPreviewResponse
 -> f GetLifecyclePolicyPreviewResponse)
-> ((CI Text -> f (CI Text))
    -> Maybe LifecyclePolicyPreviewStatus
    -> f (Maybe LifecyclePolicyPreviewStatus))
-> (CI Text -> f (CI Text))
-> GetLifecyclePolicyPreviewResponse
-> f GetLifecyclePolicyPreviewResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (LifecyclePolicyPreviewStatus -> f LifecyclePolicyPreviewStatus)
-> Maybe LifecyclePolicyPreviewStatus
-> f (Maybe LifecyclePolicyPreviewStatus)
forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just
                ((LifecyclePolicyPreviewStatus -> f LifecyclePolicyPreviewStatus)
 -> Maybe LifecyclePolicyPreviewStatus
 -> f (Maybe LifecyclePolicyPreviewStatus))
-> ((CI Text -> f (CI Text))
    -> LifecyclePolicyPreviewStatus -> f LifecyclePolicyPreviewStatus)
-> (CI Text -> f (CI Text))
-> Maybe LifecyclePolicyPreviewStatus
-> f (Maybe LifecyclePolicyPreviewStatus)
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (LifecyclePolicyPreviewStatus -> CI Text)
-> (CI Text -> f (CI Text))
-> LifecyclePolicyPreviewStatus
-> f LifecyclePolicyPreviewStatus
forall (p :: * -> * -> *) (f :: * -> *) s a.
(Profunctor p, Contravariant f) =>
(s -> a) -> Optic' p f s a
Lens.to LifecyclePolicyPreviewStatus -> CI Text
forall a. ToText a => a -> CI Text
Core.toTextCI
            ),
          CI Text
-> Accept
-> Fold (AWSResponse GetLifecyclePolicyPreview) (CI Text)
-> Acceptor GetLifecyclePolicyPreview
forall b a.
Eq b =>
b -> Accept -> Fold (AWSResponse a) b -> Acceptor a
Core.matchAll
            CI Text
"FAILED"
            Accept
Core.AcceptFailure
            ( (Maybe LifecyclePolicyPreviewStatus
 -> f (Maybe LifecyclePolicyPreviewStatus))
-> GetLifecyclePolicyPreviewResponse
-> f GetLifecyclePolicyPreviewResponse
Lens'
  GetLifecyclePolicyPreviewResponse
  (Maybe LifecyclePolicyPreviewStatus)
getLifecyclePolicyPreviewResponse_status
                ((Maybe LifecyclePolicyPreviewStatus
  -> f (Maybe LifecyclePolicyPreviewStatus))
 -> GetLifecyclePolicyPreviewResponse
 -> f GetLifecyclePolicyPreviewResponse)
-> ((CI Text -> f (CI Text))
    -> Maybe LifecyclePolicyPreviewStatus
    -> f (Maybe LifecyclePolicyPreviewStatus))
-> (CI Text -> f (CI Text))
-> GetLifecyclePolicyPreviewResponse
-> f GetLifecyclePolicyPreviewResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (LifecyclePolicyPreviewStatus -> f LifecyclePolicyPreviewStatus)
-> Maybe LifecyclePolicyPreviewStatus
-> f (Maybe LifecyclePolicyPreviewStatus)
forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just
                ((LifecyclePolicyPreviewStatus -> f LifecyclePolicyPreviewStatus)
 -> Maybe LifecyclePolicyPreviewStatus
 -> f (Maybe LifecyclePolicyPreviewStatus))
-> ((CI Text -> f (CI Text))
    -> LifecyclePolicyPreviewStatus -> f LifecyclePolicyPreviewStatus)
-> (CI Text -> f (CI Text))
-> Maybe LifecyclePolicyPreviewStatus
-> f (Maybe LifecyclePolicyPreviewStatus)
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (LifecyclePolicyPreviewStatus -> CI Text)
-> (CI Text -> f (CI Text))
-> LifecyclePolicyPreviewStatus
-> f LifecyclePolicyPreviewStatus
forall (p :: * -> * -> *) (f :: * -> *) s a.
(Profunctor p, Contravariant f) =>
(s -> a) -> Optic' p f s a
Lens.to LifecyclePolicyPreviewStatus -> CI Text
forall a. ToText a => a -> CI Text
Core.toTextCI
            )
        ]
    }

-- | Polls 'Amazonka.ECR.DescribeImageScanFindings' every 5 seconds until a successful state is reached. An error is returned after 60 failed checks.
newImageScanComplete :: Core.Wait DescribeImageScanFindings
newImageScanComplete :: Wait DescribeImageScanFindings
newImageScanComplete =
  Wait :: forall a. ByteString -> Int -> Seconds -> [Acceptor a] -> Wait a
Core.Wait
    { $sel:_waitName:Wait :: ByteString
Core._waitName = ByteString
"ImageScanComplete",
      $sel:_waitAttempts:Wait :: Int
Core._waitAttempts = Int
60,
      $sel:_waitDelay:Wait :: Seconds
Core._waitDelay = Seconds
5,
      $sel:_waitAcceptors:Wait :: [Acceptor DescribeImageScanFindings]
Core._waitAcceptors =
        [ CI Text
-> Accept
-> Fold (AWSResponse DescribeImageScanFindings) (CI Text)
-> Acceptor DescribeImageScanFindings
forall b a.
Eq b =>
b -> Accept -> Fold (AWSResponse a) b -> Acceptor a
Core.matchAll
            CI Text
"COMPLETE"
            Accept
Core.AcceptSuccess
            ( (Maybe ImageScanStatus -> f (Maybe ImageScanStatus))
-> DescribeImageScanFindingsResponse
-> f DescribeImageScanFindingsResponse
Lens' DescribeImageScanFindingsResponse (Maybe ImageScanStatus)
describeImageScanFindingsResponse_imageScanStatus
                ((Maybe ImageScanStatus -> f (Maybe ImageScanStatus))
 -> DescribeImageScanFindingsResponse
 -> f DescribeImageScanFindingsResponse)
-> ((CI Text -> f (CI Text))
    -> Maybe ImageScanStatus -> f (Maybe ImageScanStatus))
-> (CI Text -> f (CI Text))
-> DescribeImageScanFindingsResponse
-> f DescribeImageScanFindingsResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (ImageScanStatus -> f ImageScanStatus)
-> Maybe ImageScanStatus -> f (Maybe ImageScanStatus)
forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just
                ((ImageScanStatus -> f ImageScanStatus)
 -> Maybe ImageScanStatus -> f (Maybe ImageScanStatus))
-> ((CI Text -> f (CI Text))
    -> ImageScanStatus -> f ImageScanStatus)
-> (CI Text -> f (CI Text))
-> Maybe ImageScanStatus
-> f (Maybe ImageScanStatus)
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (Maybe ScanStatus -> f (Maybe ScanStatus))
-> ImageScanStatus -> f ImageScanStatus
Lens' ImageScanStatus (Maybe ScanStatus)
imageScanStatus_status
                ((Maybe ScanStatus -> f (Maybe ScanStatus))
 -> ImageScanStatus -> f ImageScanStatus)
-> ((CI Text -> f (CI Text))
    -> Maybe ScanStatus -> f (Maybe ScanStatus))
-> (CI Text -> f (CI Text))
-> ImageScanStatus
-> f ImageScanStatus
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (ScanStatus -> f ScanStatus)
-> Maybe ScanStatus -> f (Maybe ScanStatus)
forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just
                ((ScanStatus -> f ScanStatus)
 -> Maybe ScanStatus -> f (Maybe ScanStatus))
-> ((CI Text -> f (CI Text)) -> ScanStatus -> f ScanStatus)
-> (CI Text -> f (CI Text))
-> Maybe ScanStatus
-> f (Maybe ScanStatus)
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (ScanStatus -> CI Text)
-> (CI Text -> f (CI Text)) -> ScanStatus -> f ScanStatus
forall (p :: * -> * -> *) (f :: * -> *) s a.
(Profunctor p, Contravariant f) =>
(s -> a) -> Optic' p f s a
Lens.to ScanStatus -> CI Text
forall a. ToText a => a -> CI Text
Core.toTextCI
            ),
          CI Text
-> Accept
-> Fold (AWSResponse DescribeImageScanFindings) (CI Text)
-> Acceptor DescribeImageScanFindings
forall b a.
Eq b =>
b -> Accept -> Fold (AWSResponse a) b -> Acceptor a
Core.matchAll
            CI Text
"FAILED"
            Accept
Core.AcceptFailure
            ( (Maybe ImageScanStatus -> f (Maybe ImageScanStatus))
-> DescribeImageScanFindingsResponse
-> f DescribeImageScanFindingsResponse
Lens' DescribeImageScanFindingsResponse (Maybe ImageScanStatus)
describeImageScanFindingsResponse_imageScanStatus
                ((Maybe ImageScanStatus -> f (Maybe ImageScanStatus))
 -> DescribeImageScanFindingsResponse
 -> f DescribeImageScanFindingsResponse)
-> ((CI Text -> f (CI Text))
    -> Maybe ImageScanStatus -> f (Maybe ImageScanStatus))
-> (CI Text -> f (CI Text))
-> DescribeImageScanFindingsResponse
-> f DescribeImageScanFindingsResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (ImageScanStatus -> f ImageScanStatus)
-> Maybe ImageScanStatus -> f (Maybe ImageScanStatus)
forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just
                ((ImageScanStatus -> f ImageScanStatus)
 -> Maybe ImageScanStatus -> f (Maybe ImageScanStatus))
-> ((CI Text -> f (CI Text))
    -> ImageScanStatus -> f ImageScanStatus)
-> (CI Text -> f (CI Text))
-> Maybe ImageScanStatus
-> f (Maybe ImageScanStatus)
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (Maybe ScanStatus -> f (Maybe ScanStatus))
-> ImageScanStatus -> f ImageScanStatus
Lens' ImageScanStatus (Maybe ScanStatus)
imageScanStatus_status
                ((Maybe ScanStatus -> f (Maybe ScanStatus))
 -> ImageScanStatus -> f ImageScanStatus)
-> ((CI Text -> f (CI Text))
    -> Maybe ScanStatus -> f (Maybe ScanStatus))
-> (CI Text -> f (CI Text))
-> ImageScanStatus
-> f ImageScanStatus
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (ScanStatus -> f ScanStatus)
-> Maybe ScanStatus -> f (Maybe ScanStatus)
forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just
                ((ScanStatus -> f ScanStatus)
 -> Maybe ScanStatus -> f (Maybe ScanStatus))
-> ((CI Text -> f (CI Text)) -> ScanStatus -> f ScanStatus)
-> (CI Text -> f (CI Text))
-> Maybe ScanStatus
-> f (Maybe ScanStatus)
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (ScanStatus -> CI Text)
-> (CI Text -> f (CI Text)) -> ScanStatus -> f ScanStatus
forall (p :: * -> * -> *) (f :: * -> *) s a.
(Profunctor p, Contravariant f) =>
(s -> a) -> Optic' p f s a
Lens.to ScanStatus -> CI Text
forall a. ToText a => a -> CI Text
Core.toTextCI
            )
        ]
    }