{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE StrictData #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# OPTIONS_GHC -fno-warn-unused-imports #-}
{-# OPTIONS_GHC -fno-warn-unused-matches #-}

-- Derived from AWS service descriptions, licensed under Apache 2.0.

-- |
-- Module      : Amazonka.ECR.Types.ImageScanFindingsSummary
-- 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.Types.ImageScanFindingsSummary where

import qualified Amazonka.Core as Core
import Amazonka.ECR.Types.FindingSeverity
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | A summary of the last completed image scan.
--
-- /See:/ 'newImageScanFindingsSummary' smart constructor.
data ImageScanFindingsSummary = ImageScanFindingsSummary'
  { -- | The time of the last completed image scan.
    ImageScanFindingsSummary -> Maybe POSIX
imageScanCompletedAt :: Prelude.Maybe Core.POSIX,
    -- | The image vulnerability counts, sorted by severity.
    ImageScanFindingsSummary -> Maybe (HashMap FindingSeverity Natural)
findingSeverityCounts :: Prelude.Maybe (Prelude.HashMap FindingSeverity Prelude.Natural),
    -- | The time when the vulnerability data was last scanned.
    ImageScanFindingsSummary -> Maybe POSIX
vulnerabilitySourceUpdatedAt :: Prelude.Maybe Core.POSIX
  }
  deriving (ImageScanFindingsSummary -> ImageScanFindingsSummary -> Bool
(ImageScanFindingsSummary -> ImageScanFindingsSummary -> Bool)
-> (ImageScanFindingsSummary -> ImageScanFindingsSummary -> Bool)
-> Eq ImageScanFindingsSummary
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ImageScanFindingsSummary -> ImageScanFindingsSummary -> Bool
$c/= :: ImageScanFindingsSummary -> ImageScanFindingsSummary -> Bool
== :: ImageScanFindingsSummary -> ImageScanFindingsSummary -> Bool
$c== :: ImageScanFindingsSummary -> ImageScanFindingsSummary -> Bool
Prelude.Eq, ReadPrec [ImageScanFindingsSummary]
ReadPrec ImageScanFindingsSummary
Int -> ReadS ImageScanFindingsSummary
ReadS [ImageScanFindingsSummary]
(Int -> ReadS ImageScanFindingsSummary)
-> ReadS [ImageScanFindingsSummary]
-> ReadPrec ImageScanFindingsSummary
-> ReadPrec [ImageScanFindingsSummary]
-> Read ImageScanFindingsSummary
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ImageScanFindingsSummary]
$creadListPrec :: ReadPrec [ImageScanFindingsSummary]
readPrec :: ReadPrec ImageScanFindingsSummary
$creadPrec :: ReadPrec ImageScanFindingsSummary
readList :: ReadS [ImageScanFindingsSummary]
$creadList :: ReadS [ImageScanFindingsSummary]
readsPrec :: Int -> ReadS ImageScanFindingsSummary
$creadsPrec :: Int -> ReadS ImageScanFindingsSummary
Prelude.Read, Int -> ImageScanFindingsSummary -> ShowS
[ImageScanFindingsSummary] -> ShowS
ImageScanFindingsSummary -> String
(Int -> ImageScanFindingsSummary -> ShowS)
-> (ImageScanFindingsSummary -> String)
-> ([ImageScanFindingsSummary] -> ShowS)
-> Show ImageScanFindingsSummary
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ImageScanFindingsSummary] -> ShowS
$cshowList :: [ImageScanFindingsSummary] -> ShowS
show :: ImageScanFindingsSummary -> String
$cshow :: ImageScanFindingsSummary -> String
showsPrec :: Int -> ImageScanFindingsSummary -> ShowS
$cshowsPrec :: Int -> ImageScanFindingsSummary -> ShowS
Prelude.Show, (forall x.
 ImageScanFindingsSummary -> Rep ImageScanFindingsSummary x)
-> (forall x.
    Rep ImageScanFindingsSummary x -> ImageScanFindingsSummary)
-> Generic ImageScanFindingsSummary
forall x.
Rep ImageScanFindingsSummary x -> ImageScanFindingsSummary
forall x.
ImageScanFindingsSummary -> Rep ImageScanFindingsSummary x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep ImageScanFindingsSummary x -> ImageScanFindingsSummary
$cfrom :: forall x.
ImageScanFindingsSummary -> Rep ImageScanFindingsSummary x
Prelude.Generic)

-- |
-- Create a value of 'ImageScanFindingsSummary' with all optional fields omitted.
--
-- Use <https://hackage.haskell.org/package/generic-lens generic-lens> or <https://hackage.haskell.org/package/optics optics> to modify other optional fields.
--
-- The following record fields are available, with the corresponding lenses provided
-- for backwards compatibility:
--
-- 'imageScanCompletedAt', 'imageScanFindingsSummary_imageScanCompletedAt' - The time of the last completed image scan.
--
-- 'findingSeverityCounts', 'imageScanFindingsSummary_findingSeverityCounts' - The image vulnerability counts, sorted by severity.
--
-- 'vulnerabilitySourceUpdatedAt', 'imageScanFindingsSummary_vulnerabilitySourceUpdatedAt' - The time when the vulnerability data was last scanned.
newImageScanFindingsSummary ::
  ImageScanFindingsSummary
newImageScanFindingsSummary :: ImageScanFindingsSummary
newImageScanFindingsSummary =
  ImageScanFindingsSummary' :: Maybe POSIX
-> Maybe (HashMap FindingSeverity Natural)
-> Maybe POSIX
-> ImageScanFindingsSummary
ImageScanFindingsSummary'
    { $sel:imageScanCompletedAt:ImageScanFindingsSummary' :: Maybe POSIX
imageScanCompletedAt =
        Maybe POSIX
forall a. Maybe a
Prelude.Nothing,
      $sel:findingSeverityCounts:ImageScanFindingsSummary' :: Maybe (HashMap FindingSeverity Natural)
findingSeverityCounts = Maybe (HashMap FindingSeverity Natural)
forall a. Maybe a
Prelude.Nothing,
      $sel:vulnerabilitySourceUpdatedAt:ImageScanFindingsSummary' :: Maybe POSIX
vulnerabilitySourceUpdatedAt = Maybe POSIX
forall a. Maybe a
Prelude.Nothing
    }

-- | The time of the last completed image scan.
imageScanFindingsSummary_imageScanCompletedAt :: Lens.Lens' ImageScanFindingsSummary (Prelude.Maybe Prelude.UTCTime)
imageScanFindingsSummary_imageScanCompletedAt :: (Maybe UTCTime -> f (Maybe UTCTime))
-> ImageScanFindingsSummary -> f ImageScanFindingsSummary
imageScanFindingsSummary_imageScanCompletedAt = (ImageScanFindingsSummary -> Maybe POSIX)
-> (ImageScanFindingsSummary
    -> Maybe POSIX -> ImageScanFindingsSummary)
-> Lens
     ImageScanFindingsSummary
     ImageScanFindingsSummary
     (Maybe POSIX)
     (Maybe POSIX)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ImageScanFindingsSummary' {Maybe POSIX
imageScanCompletedAt :: Maybe POSIX
$sel:imageScanCompletedAt:ImageScanFindingsSummary' :: ImageScanFindingsSummary -> Maybe POSIX
imageScanCompletedAt} -> Maybe POSIX
imageScanCompletedAt) (\s :: ImageScanFindingsSummary
s@ImageScanFindingsSummary' {} Maybe POSIX
a -> ImageScanFindingsSummary
s {$sel:imageScanCompletedAt:ImageScanFindingsSummary' :: Maybe POSIX
imageScanCompletedAt = Maybe POSIX
a} :: ImageScanFindingsSummary) ((Maybe POSIX -> f (Maybe POSIX))
 -> ImageScanFindingsSummary -> f ImageScanFindingsSummary)
-> ((Maybe UTCTime -> f (Maybe UTCTime))
    -> Maybe POSIX -> f (Maybe POSIX))
-> (Maybe UTCTime -> f (Maybe UTCTime))
-> ImageScanFindingsSummary
-> f ImageScanFindingsSummary
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso POSIX POSIX UTCTime UTCTime
-> Iso (Maybe POSIX) (Maybe POSIX) (Maybe UTCTime) (Maybe UTCTime)
forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping AnIso POSIX POSIX UTCTime UTCTime
forall (a :: Format). Iso' (Time a) UTCTime
Core._Time

-- | The image vulnerability counts, sorted by severity.
imageScanFindingsSummary_findingSeverityCounts :: Lens.Lens' ImageScanFindingsSummary (Prelude.Maybe (Prelude.HashMap FindingSeverity Prelude.Natural))
imageScanFindingsSummary_findingSeverityCounts :: (Maybe (HashMap FindingSeverity Natural)
 -> f (Maybe (HashMap FindingSeverity Natural)))
-> ImageScanFindingsSummary -> f ImageScanFindingsSummary
imageScanFindingsSummary_findingSeverityCounts = (ImageScanFindingsSummary
 -> Maybe (HashMap FindingSeverity Natural))
-> (ImageScanFindingsSummary
    -> Maybe (HashMap FindingSeverity Natural)
    -> ImageScanFindingsSummary)
-> Lens
     ImageScanFindingsSummary
     ImageScanFindingsSummary
     (Maybe (HashMap FindingSeverity Natural))
     (Maybe (HashMap FindingSeverity Natural))
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ImageScanFindingsSummary' {Maybe (HashMap FindingSeverity Natural)
findingSeverityCounts :: Maybe (HashMap FindingSeverity Natural)
$sel:findingSeverityCounts:ImageScanFindingsSummary' :: ImageScanFindingsSummary -> Maybe (HashMap FindingSeverity Natural)
findingSeverityCounts} -> Maybe (HashMap FindingSeverity Natural)
findingSeverityCounts) (\s :: ImageScanFindingsSummary
s@ImageScanFindingsSummary' {} Maybe (HashMap FindingSeverity Natural)
a -> ImageScanFindingsSummary
s {$sel:findingSeverityCounts:ImageScanFindingsSummary' :: Maybe (HashMap FindingSeverity Natural)
findingSeverityCounts = Maybe (HashMap FindingSeverity Natural)
a} :: ImageScanFindingsSummary) ((Maybe (HashMap FindingSeverity Natural)
  -> f (Maybe (HashMap FindingSeverity Natural)))
 -> ImageScanFindingsSummary -> f ImageScanFindingsSummary)
-> ((Maybe (HashMap FindingSeverity Natural)
     -> f (Maybe (HashMap FindingSeverity Natural)))
    -> Maybe (HashMap FindingSeverity Natural)
    -> f (Maybe (HashMap FindingSeverity Natural)))
-> (Maybe (HashMap FindingSeverity Natural)
    -> f (Maybe (HashMap FindingSeverity Natural)))
-> ImageScanFindingsSummary
-> f ImageScanFindingsSummary
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  (HashMap FindingSeverity Natural)
  (HashMap FindingSeverity Natural)
  (HashMap FindingSeverity Natural)
  (HashMap FindingSeverity Natural)
-> Iso
     (Maybe (HashMap FindingSeverity Natural))
     (Maybe (HashMap FindingSeverity Natural))
     (Maybe (HashMap FindingSeverity Natural))
     (Maybe (HashMap FindingSeverity Natural))
forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping AnIso
  (HashMap FindingSeverity Natural)
  (HashMap FindingSeverity Natural)
  (HashMap FindingSeverity Natural)
  (HashMap FindingSeverity Natural)
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The time when the vulnerability data was last scanned.
imageScanFindingsSummary_vulnerabilitySourceUpdatedAt :: Lens.Lens' ImageScanFindingsSummary (Prelude.Maybe Prelude.UTCTime)
imageScanFindingsSummary_vulnerabilitySourceUpdatedAt :: (Maybe UTCTime -> f (Maybe UTCTime))
-> ImageScanFindingsSummary -> f ImageScanFindingsSummary
imageScanFindingsSummary_vulnerabilitySourceUpdatedAt = (ImageScanFindingsSummary -> Maybe POSIX)
-> (ImageScanFindingsSummary
    -> Maybe POSIX -> ImageScanFindingsSummary)
-> Lens
     ImageScanFindingsSummary
     ImageScanFindingsSummary
     (Maybe POSIX)
     (Maybe POSIX)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ImageScanFindingsSummary' {Maybe POSIX
vulnerabilitySourceUpdatedAt :: Maybe POSIX
$sel:vulnerabilitySourceUpdatedAt:ImageScanFindingsSummary' :: ImageScanFindingsSummary -> Maybe POSIX
vulnerabilitySourceUpdatedAt} -> Maybe POSIX
vulnerabilitySourceUpdatedAt) (\s :: ImageScanFindingsSummary
s@ImageScanFindingsSummary' {} Maybe POSIX
a -> ImageScanFindingsSummary
s {$sel:vulnerabilitySourceUpdatedAt:ImageScanFindingsSummary' :: Maybe POSIX
vulnerabilitySourceUpdatedAt = Maybe POSIX
a} :: ImageScanFindingsSummary) ((Maybe POSIX -> f (Maybe POSIX))
 -> ImageScanFindingsSummary -> f ImageScanFindingsSummary)
-> ((Maybe UTCTime -> f (Maybe UTCTime))
    -> Maybe POSIX -> f (Maybe POSIX))
-> (Maybe UTCTime -> f (Maybe UTCTime))
-> ImageScanFindingsSummary
-> f ImageScanFindingsSummary
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso POSIX POSIX UTCTime UTCTime
-> Iso (Maybe POSIX) (Maybe POSIX) (Maybe UTCTime) (Maybe UTCTime)
forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping AnIso POSIX POSIX UTCTime UTCTime
forall (a :: Format). Iso' (Time a) UTCTime
Core._Time

instance Core.FromJSON ImageScanFindingsSummary where
  parseJSON :: Value -> Parser ImageScanFindingsSummary
parseJSON =
    String
-> (Object -> Parser ImageScanFindingsSummary)
-> Value
-> Parser ImageScanFindingsSummary
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"ImageScanFindingsSummary"
      ( \Object
x ->
          Maybe POSIX
-> Maybe (HashMap FindingSeverity Natural)
-> Maybe POSIX
-> ImageScanFindingsSummary
ImageScanFindingsSummary'
            (Maybe POSIX
 -> Maybe (HashMap FindingSeverity Natural)
 -> Maybe POSIX
 -> ImageScanFindingsSummary)
-> Parser (Maybe POSIX)
-> Parser
     (Maybe (HashMap FindingSeverity Natural)
      -> Maybe POSIX -> ImageScanFindingsSummary)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe POSIX)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"imageScanCompletedAt")
            Parser
  (Maybe (HashMap FindingSeverity Natural)
   -> Maybe POSIX -> ImageScanFindingsSummary)
-> Parser (Maybe (HashMap FindingSeverity Natural))
-> Parser (Maybe POSIX -> ImageScanFindingsSummary)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ( Object
x Object
-> Text -> Parser (Maybe (Maybe (HashMap FindingSeverity Natural)))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"findingSeverityCounts"
                            Parser (Maybe (Maybe (HashMap FindingSeverity Natural)))
-> Maybe (HashMap FindingSeverity Natural)
-> Parser (Maybe (HashMap FindingSeverity Natural))
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe (HashMap FindingSeverity Natural)
forall a. Monoid a => a
Prelude.mempty
                        )
            Parser (Maybe POSIX -> ImageScanFindingsSummary)
-> Parser (Maybe POSIX) -> Parser ImageScanFindingsSummary
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe POSIX)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"vulnerabilitySourceUpdatedAt")
      )

instance Prelude.Hashable ImageScanFindingsSummary

instance Prelude.NFData ImageScanFindingsSummary