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

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

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

-- |
-- Create a value of 'ImageScanFindings' 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', 'imageScanFindings_imageScanCompletedAt' - The time of the last completed image scan.
--
-- 'findings', 'imageScanFindings_findings' - The findings from the image scan.
--
-- 'findingSeverityCounts', 'imageScanFindings_findingSeverityCounts' - The image vulnerability counts, sorted by severity.
--
-- 'vulnerabilitySourceUpdatedAt', 'imageScanFindings_vulnerabilitySourceUpdatedAt' - The time when the vulnerability data was last scanned.
newImageScanFindings ::
  ImageScanFindings
newImageScanFindings :: ImageScanFindings
newImageScanFindings =
  ImageScanFindings' :: Maybe POSIX
-> Maybe [ImageScanFinding]
-> Maybe (HashMap FindingSeverity Natural)
-> Maybe POSIX
-> ImageScanFindings
ImageScanFindings'
    { $sel:imageScanCompletedAt:ImageScanFindings' :: Maybe POSIX
imageScanCompletedAt =
        Maybe POSIX
forall a. Maybe a
Prelude.Nothing,
      $sel:findings:ImageScanFindings' :: Maybe [ImageScanFinding]
findings = Maybe [ImageScanFinding]
forall a. Maybe a
Prelude.Nothing,
      $sel:findingSeverityCounts:ImageScanFindings' :: Maybe (HashMap FindingSeverity Natural)
findingSeverityCounts = Maybe (HashMap FindingSeverity Natural)
forall a. Maybe a
Prelude.Nothing,
      $sel:vulnerabilitySourceUpdatedAt:ImageScanFindings' :: Maybe POSIX
vulnerabilitySourceUpdatedAt = Maybe POSIX
forall a. Maybe a
Prelude.Nothing
    }

-- | The time of the last completed image scan.
imageScanFindings_imageScanCompletedAt :: Lens.Lens' ImageScanFindings (Prelude.Maybe Prelude.UTCTime)
imageScanFindings_imageScanCompletedAt :: (Maybe UTCTime -> f (Maybe UTCTime))
-> ImageScanFindings -> f ImageScanFindings
imageScanFindings_imageScanCompletedAt = (ImageScanFindings -> Maybe POSIX)
-> (ImageScanFindings -> Maybe POSIX -> ImageScanFindings)
-> Lens
     ImageScanFindings ImageScanFindings (Maybe POSIX) (Maybe POSIX)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ImageScanFindings' {Maybe POSIX
imageScanCompletedAt :: Maybe POSIX
$sel:imageScanCompletedAt:ImageScanFindings' :: ImageScanFindings -> Maybe POSIX
imageScanCompletedAt} -> Maybe POSIX
imageScanCompletedAt) (\s :: ImageScanFindings
s@ImageScanFindings' {} Maybe POSIX
a -> ImageScanFindings
s {$sel:imageScanCompletedAt:ImageScanFindings' :: Maybe POSIX
imageScanCompletedAt = Maybe POSIX
a} :: ImageScanFindings) ((Maybe POSIX -> f (Maybe POSIX))
 -> ImageScanFindings -> f ImageScanFindings)
-> ((Maybe UTCTime -> f (Maybe UTCTime))
    -> Maybe POSIX -> f (Maybe POSIX))
-> (Maybe UTCTime -> f (Maybe UTCTime))
-> ImageScanFindings
-> f ImageScanFindings
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 findings from the image scan.
imageScanFindings_findings :: Lens.Lens' ImageScanFindings (Prelude.Maybe [ImageScanFinding])
imageScanFindings_findings :: (Maybe [ImageScanFinding] -> f (Maybe [ImageScanFinding]))
-> ImageScanFindings -> f ImageScanFindings
imageScanFindings_findings = (ImageScanFindings -> Maybe [ImageScanFinding])
-> (ImageScanFindings
    -> Maybe [ImageScanFinding] -> ImageScanFindings)
-> Lens
     ImageScanFindings
     ImageScanFindings
     (Maybe [ImageScanFinding])
     (Maybe [ImageScanFinding])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ImageScanFindings' {Maybe [ImageScanFinding]
findings :: Maybe [ImageScanFinding]
$sel:findings:ImageScanFindings' :: ImageScanFindings -> Maybe [ImageScanFinding]
findings} -> Maybe [ImageScanFinding]
findings) (\s :: ImageScanFindings
s@ImageScanFindings' {} Maybe [ImageScanFinding]
a -> ImageScanFindings
s {$sel:findings:ImageScanFindings' :: Maybe [ImageScanFinding]
findings = Maybe [ImageScanFinding]
a} :: ImageScanFindings) ((Maybe [ImageScanFinding] -> f (Maybe [ImageScanFinding]))
 -> ImageScanFindings -> f ImageScanFindings)
-> ((Maybe [ImageScanFinding] -> f (Maybe [ImageScanFinding]))
    -> Maybe [ImageScanFinding] -> f (Maybe [ImageScanFinding]))
-> (Maybe [ImageScanFinding] -> f (Maybe [ImageScanFinding]))
-> ImageScanFindings
-> f ImageScanFindings
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  [ImageScanFinding]
  [ImageScanFinding]
  [ImageScanFinding]
  [ImageScanFinding]
-> Iso
     (Maybe [ImageScanFinding])
     (Maybe [ImageScanFinding])
     (Maybe [ImageScanFinding])
     (Maybe [ImageScanFinding])
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
  [ImageScanFinding]
  [ImageScanFinding]
  [ImageScanFinding]
  [ImageScanFinding]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The image vulnerability counts, sorted by severity.
imageScanFindings_findingSeverityCounts :: Lens.Lens' ImageScanFindings (Prelude.Maybe (Prelude.HashMap FindingSeverity Prelude.Natural))
imageScanFindings_findingSeverityCounts :: (Maybe (HashMap FindingSeverity Natural)
 -> f (Maybe (HashMap FindingSeverity Natural)))
-> ImageScanFindings -> f ImageScanFindings
imageScanFindings_findingSeverityCounts = (ImageScanFindings -> Maybe (HashMap FindingSeverity Natural))
-> (ImageScanFindings
    -> Maybe (HashMap FindingSeverity Natural) -> ImageScanFindings)
-> Lens
     ImageScanFindings
     ImageScanFindings
     (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 (\ImageScanFindings' {Maybe (HashMap FindingSeverity Natural)
findingSeverityCounts :: Maybe (HashMap FindingSeverity Natural)
$sel:findingSeverityCounts:ImageScanFindings' :: ImageScanFindings -> Maybe (HashMap FindingSeverity Natural)
findingSeverityCounts} -> Maybe (HashMap FindingSeverity Natural)
findingSeverityCounts) (\s :: ImageScanFindings
s@ImageScanFindings' {} Maybe (HashMap FindingSeverity Natural)
a -> ImageScanFindings
s {$sel:findingSeverityCounts:ImageScanFindings' :: Maybe (HashMap FindingSeverity Natural)
findingSeverityCounts = Maybe (HashMap FindingSeverity Natural)
a} :: ImageScanFindings) ((Maybe (HashMap FindingSeverity Natural)
  -> f (Maybe (HashMap FindingSeverity Natural)))
 -> ImageScanFindings -> f ImageScanFindings)
-> ((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)))
-> ImageScanFindings
-> f ImageScanFindings
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.
imageScanFindings_vulnerabilitySourceUpdatedAt :: Lens.Lens' ImageScanFindings (Prelude.Maybe Prelude.UTCTime)
imageScanFindings_vulnerabilitySourceUpdatedAt :: (Maybe UTCTime -> f (Maybe UTCTime))
-> ImageScanFindings -> f ImageScanFindings
imageScanFindings_vulnerabilitySourceUpdatedAt = (ImageScanFindings -> Maybe POSIX)
-> (ImageScanFindings -> Maybe POSIX -> ImageScanFindings)
-> Lens
     ImageScanFindings ImageScanFindings (Maybe POSIX) (Maybe POSIX)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ImageScanFindings' {Maybe POSIX
vulnerabilitySourceUpdatedAt :: Maybe POSIX
$sel:vulnerabilitySourceUpdatedAt:ImageScanFindings' :: ImageScanFindings -> Maybe POSIX
vulnerabilitySourceUpdatedAt} -> Maybe POSIX
vulnerabilitySourceUpdatedAt) (\s :: ImageScanFindings
s@ImageScanFindings' {} Maybe POSIX
a -> ImageScanFindings
s {$sel:vulnerabilitySourceUpdatedAt:ImageScanFindings' :: Maybe POSIX
vulnerabilitySourceUpdatedAt = Maybe POSIX
a} :: ImageScanFindings) ((Maybe POSIX -> f (Maybe POSIX))
 -> ImageScanFindings -> f ImageScanFindings)
-> ((Maybe UTCTime -> f (Maybe UTCTime))
    -> Maybe POSIX -> f (Maybe POSIX))
-> (Maybe UTCTime -> f (Maybe UTCTime))
-> ImageScanFindings
-> f ImageScanFindings
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 ImageScanFindings where
  parseJSON :: Value -> Parser ImageScanFindings
parseJSON =
    String
-> (Object -> Parser ImageScanFindings)
-> Value
-> Parser ImageScanFindings
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"ImageScanFindings"
      ( \Object
x ->
          Maybe POSIX
-> Maybe [ImageScanFinding]
-> Maybe (HashMap FindingSeverity Natural)
-> Maybe POSIX
-> ImageScanFindings
ImageScanFindings'
            (Maybe POSIX
 -> Maybe [ImageScanFinding]
 -> Maybe (HashMap FindingSeverity Natural)
 -> Maybe POSIX
 -> ImageScanFindings)
-> Parser (Maybe POSIX)
-> Parser
     (Maybe [ImageScanFinding]
      -> Maybe (HashMap FindingSeverity Natural)
      -> Maybe POSIX
      -> ImageScanFindings)
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 [ImageScanFinding]
   -> Maybe (HashMap FindingSeverity Natural)
   -> Maybe POSIX
   -> ImageScanFindings)
-> Parser (Maybe [ImageScanFinding])
-> Parser
     (Maybe (HashMap FindingSeverity Natural)
      -> Maybe POSIX -> ImageScanFindings)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe (Maybe [ImageScanFinding]))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"findings" Parser (Maybe (Maybe [ImageScanFinding]))
-> Maybe [ImageScanFinding] -> Parser (Maybe [ImageScanFinding])
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe [ImageScanFinding]
forall a. Monoid a => a
Prelude.mempty)
            Parser
  (Maybe (HashMap FindingSeverity Natural)
   -> Maybe POSIX -> ImageScanFindings)
-> Parser (Maybe (HashMap FindingSeverity Natural))
-> Parser (Maybe POSIX -> ImageScanFindings)
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 -> ImageScanFindings)
-> Parser (Maybe POSIX) -> Parser ImageScanFindings
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 ImageScanFindings

instance Prelude.NFData ImageScanFindings