{-# 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.AuditManager.Types.InsightsByAssessment
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.AuditManager.Types.InsightsByAssessment where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import qualified Amazonka.Prelude as Prelude

-- | A summary of the latest analytics data for a specific active assessment.
--
-- This summary is a snapshot of the data that was collected on the
-- @lastUpdated@ date. It’s important to understand that the totals in
-- @InsightsByAssessment@ are daily counts based on this date — they aren’t
-- a total sum to date.
--
-- The @InsightsByAssessment@ data is eventually consistent. This means
-- that when you read data from @InsightsByAssessment@, the response might
-- not instantly reflect the results of a recently completed write or
-- update operation. If you repeat your read request after a few hours, the
-- response returns the latest data.
--
-- If you delete an assessment or change its status to inactive,
-- @InsightsByAssessment@ includes data for that assessment as follows.
--
-- -   __Inactive assessments__ - If Audit Manager collected evidence for
--     your assessment before you changed it inactive, that evidence is
--     included in the @InsightsByAssessment@ counts for that day.
--
-- -   __Deleted assessments__ - If Audit Manager collected evidence for
--     your assessment before you deleted it, that evidence isn\'t included
--     in the @InsightsByAssessment@ counts for that day.
--
-- /See:/ 'newInsightsByAssessment' smart constructor.
data InsightsByAssessment = InsightsByAssessment'
  { -- | The number of assessment controls that collected non-compliant evidence
    -- on the @lastUpdated@ date.
    InsightsByAssessment -> Maybe Int
assessmentControlsCountByNoncompliantEvidence :: Prelude.Maybe Prelude.Int,
    -- | The number of compliance check evidence that Audit Manager classified as
    -- compliant. This includes evidence that was collected from Security Hub
    -- with a /Pass/ ruling, or collected from Config with a /Compliant/
    -- ruling.
    InsightsByAssessment -> Maybe Int
compliantEvidenceCount :: Prelude.Maybe Prelude.Int,
    -- | The amount of evidence without a compliance check ruling. Evidence is
    -- inconclusive if the associated control uses Security Hub or Config as a
    -- data source and you didn\'t enable those services. This is also the case
    -- if a control uses a data source that doesn’t support compliance checks
    -- (for example, manual evidence, API calls, or CloudTrail).
    --
    -- If evidence has a compliance check status of /not applicable/, it\'s
    -- classified as /inconclusive/ in @InsightsByAssessment@ data.
    InsightsByAssessment -> Maybe Int
inconclusiveEvidenceCount :: Prelude.Maybe Prelude.Int,
    -- | The time when the assessment insights were last updated.
    InsightsByAssessment -> Maybe POSIX
lastUpdated :: Prelude.Maybe Data.POSIX,
    -- | The number of compliance check evidence that Audit Manager classified as
    -- non-compliant. This includes evidence that was collected from Security
    -- Hub with a /Fail/ ruling, or collected from Config with a
    -- /Non-compliant/ ruling.
    InsightsByAssessment -> Maybe Int
noncompliantEvidenceCount :: Prelude.Maybe Prelude.Int,
    -- | The total number of controls in the assessment.
    InsightsByAssessment -> Maybe Int
totalAssessmentControlsCount :: Prelude.Maybe Prelude.Int
  }
  deriving (InsightsByAssessment -> InsightsByAssessment -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: InsightsByAssessment -> InsightsByAssessment -> Bool
$c/= :: InsightsByAssessment -> InsightsByAssessment -> Bool
== :: InsightsByAssessment -> InsightsByAssessment -> Bool
$c== :: InsightsByAssessment -> InsightsByAssessment -> Bool
Prelude.Eq, ReadPrec [InsightsByAssessment]
ReadPrec InsightsByAssessment
Int -> ReadS InsightsByAssessment
ReadS [InsightsByAssessment]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [InsightsByAssessment]
$creadListPrec :: ReadPrec [InsightsByAssessment]
readPrec :: ReadPrec InsightsByAssessment
$creadPrec :: ReadPrec InsightsByAssessment
readList :: ReadS [InsightsByAssessment]
$creadList :: ReadS [InsightsByAssessment]
readsPrec :: Int -> ReadS InsightsByAssessment
$creadsPrec :: Int -> ReadS InsightsByAssessment
Prelude.Read, Int -> InsightsByAssessment -> ShowS
[InsightsByAssessment] -> ShowS
InsightsByAssessment -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [InsightsByAssessment] -> ShowS
$cshowList :: [InsightsByAssessment] -> ShowS
show :: InsightsByAssessment -> String
$cshow :: InsightsByAssessment -> String
showsPrec :: Int -> InsightsByAssessment -> ShowS
$cshowsPrec :: Int -> InsightsByAssessment -> ShowS
Prelude.Show, forall x. Rep InsightsByAssessment x -> InsightsByAssessment
forall x. InsightsByAssessment -> Rep InsightsByAssessment x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep InsightsByAssessment x -> InsightsByAssessment
$cfrom :: forall x. InsightsByAssessment -> Rep InsightsByAssessment x
Prelude.Generic)

-- |
-- Create a value of 'InsightsByAssessment' 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:
--
-- 'assessmentControlsCountByNoncompliantEvidence', 'insightsByAssessment_assessmentControlsCountByNoncompliantEvidence' - The number of assessment controls that collected non-compliant evidence
-- on the @lastUpdated@ date.
--
-- 'compliantEvidenceCount', 'insightsByAssessment_compliantEvidenceCount' - The number of compliance check evidence that Audit Manager classified as
-- compliant. This includes evidence that was collected from Security Hub
-- with a /Pass/ ruling, or collected from Config with a /Compliant/
-- ruling.
--
-- 'inconclusiveEvidenceCount', 'insightsByAssessment_inconclusiveEvidenceCount' - The amount of evidence without a compliance check ruling. Evidence is
-- inconclusive if the associated control uses Security Hub or Config as a
-- data source and you didn\'t enable those services. This is also the case
-- if a control uses a data source that doesn’t support compliance checks
-- (for example, manual evidence, API calls, or CloudTrail).
--
-- If evidence has a compliance check status of /not applicable/, it\'s
-- classified as /inconclusive/ in @InsightsByAssessment@ data.
--
-- 'lastUpdated', 'insightsByAssessment_lastUpdated' - The time when the assessment insights were last updated.
--
-- 'noncompliantEvidenceCount', 'insightsByAssessment_noncompliantEvidenceCount' - The number of compliance check evidence that Audit Manager classified as
-- non-compliant. This includes evidence that was collected from Security
-- Hub with a /Fail/ ruling, or collected from Config with a
-- /Non-compliant/ ruling.
--
-- 'totalAssessmentControlsCount', 'insightsByAssessment_totalAssessmentControlsCount' - The total number of controls in the assessment.
newInsightsByAssessment ::
  InsightsByAssessment
newInsightsByAssessment :: InsightsByAssessment
newInsightsByAssessment =
  InsightsByAssessment'
    { $sel:assessmentControlsCountByNoncompliantEvidence:InsightsByAssessment' :: Maybe Int
assessmentControlsCountByNoncompliantEvidence =
        forall a. Maybe a
Prelude.Nothing,
      $sel:compliantEvidenceCount:InsightsByAssessment' :: Maybe Int
compliantEvidenceCount = forall a. Maybe a
Prelude.Nothing,
      $sel:inconclusiveEvidenceCount:InsightsByAssessment' :: Maybe Int
inconclusiveEvidenceCount = forall a. Maybe a
Prelude.Nothing,
      $sel:lastUpdated:InsightsByAssessment' :: Maybe POSIX
lastUpdated = forall a. Maybe a
Prelude.Nothing,
      $sel:noncompliantEvidenceCount:InsightsByAssessment' :: Maybe Int
noncompliantEvidenceCount = forall a. Maybe a
Prelude.Nothing,
      $sel:totalAssessmentControlsCount:InsightsByAssessment' :: Maybe Int
totalAssessmentControlsCount = forall a. Maybe a
Prelude.Nothing
    }

-- | The number of assessment controls that collected non-compliant evidence
-- on the @lastUpdated@ date.
insightsByAssessment_assessmentControlsCountByNoncompliantEvidence :: Lens.Lens' InsightsByAssessment (Prelude.Maybe Prelude.Int)
insightsByAssessment_assessmentControlsCountByNoncompliantEvidence :: Lens' InsightsByAssessment (Maybe Int)
insightsByAssessment_assessmentControlsCountByNoncompliantEvidence = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\InsightsByAssessment' {Maybe Int
assessmentControlsCountByNoncompliantEvidence :: Maybe Int
$sel:assessmentControlsCountByNoncompliantEvidence:InsightsByAssessment' :: InsightsByAssessment -> Maybe Int
assessmentControlsCountByNoncompliantEvidence} -> Maybe Int
assessmentControlsCountByNoncompliantEvidence) (\s :: InsightsByAssessment
s@InsightsByAssessment' {} Maybe Int
a -> InsightsByAssessment
s {$sel:assessmentControlsCountByNoncompliantEvidence:InsightsByAssessment' :: Maybe Int
assessmentControlsCountByNoncompliantEvidence = Maybe Int
a} :: InsightsByAssessment)

-- | The number of compliance check evidence that Audit Manager classified as
-- compliant. This includes evidence that was collected from Security Hub
-- with a /Pass/ ruling, or collected from Config with a /Compliant/
-- ruling.
insightsByAssessment_compliantEvidenceCount :: Lens.Lens' InsightsByAssessment (Prelude.Maybe Prelude.Int)
insightsByAssessment_compliantEvidenceCount :: Lens' InsightsByAssessment (Maybe Int)
insightsByAssessment_compliantEvidenceCount = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\InsightsByAssessment' {Maybe Int
compliantEvidenceCount :: Maybe Int
$sel:compliantEvidenceCount:InsightsByAssessment' :: InsightsByAssessment -> Maybe Int
compliantEvidenceCount} -> Maybe Int
compliantEvidenceCount) (\s :: InsightsByAssessment
s@InsightsByAssessment' {} Maybe Int
a -> InsightsByAssessment
s {$sel:compliantEvidenceCount:InsightsByAssessment' :: Maybe Int
compliantEvidenceCount = Maybe Int
a} :: InsightsByAssessment)

-- | The amount of evidence without a compliance check ruling. Evidence is
-- inconclusive if the associated control uses Security Hub or Config as a
-- data source and you didn\'t enable those services. This is also the case
-- if a control uses a data source that doesn’t support compliance checks
-- (for example, manual evidence, API calls, or CloudTrail).
--
-- If evidence has a compliance check status of /not applicable/, it\'s
-- classified as /inconclusive/ in @InsightsByAssessment@ data.
insightsByAssessment_inconclusiveEvidenceCount :: Lens.Lens' InsightsByAssessment (Prelude.Maybe Prelude.Int)
insightsByAssessment_inconclusiveEvidenceCount :: Lens' InsightsByAssessment (Maybe Int)
insightsByAssessment_inconclusiveEvidenceCount = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\InsightsByAssessment' {Maybe Int
inconclusiveEvidenceCount :: Maybe Int
$sel:inconclusiveEvidenceCount:InsightsByAssessment' :: InsightsByAssessment -> Maybe Int
inconclusiveEvidenceCount} -> Maybe Int
inconclusiveEvidenceCount) (\s :: InsightsByAssessment
s@InsightsByAssessment' {} Maybe Int
a -> InsightsByAssessment
s {$sel:inconclusiveEvidenceCount:InsightsByAssessment' :: Maybe Int
inconclusiveEvidenceCount = Maybe Int
a} :: InsightsByAssessment)

-- | The time when the assessment insights were last updated.
insightsByAssessment_lastUpdated :: Lens.Lens' InsightsByAssessment (Prelude.Maybe Prelude.UTCTime)
insightsByAssessment_lastUpdated :: Lens' InsightsByAssessment (Maybe UTCTime)
insightsByAssessment_lastUpdated = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\InsightsByAssessment' {Maybe POSIX
lastUpdated :: Maybe POSIX
$sel:lastUpdated:InsightsByAssessment' :: InsightsByAssessment -> Maybe POSIX
lastUpdated} -> Maybe POSIX
lastUpdated) (\s :: InsightsByAssessment
s@InsightsByAssessment' {} Maybe POSIX
a -> InsightsByAssessment
s {$sel:lastUpdated:InsightsByAssessment' :: Maybe POSIX
lastUpdated = Maybe POSIX
a} :: InsightsByAssessment) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. 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 forall (a :: Format). Iso' (Time a) UTCTime
Data._Time

-- | The number of compliance check evidence that Audit Manager classified as
-- non-compliant. This includes evidence that was collected from Security
-- Hub with a /Fail/ ruling, or collected from Config with a
-- /Non-compliant/ ruling.
insightsByAssessment_noncompliantEvidenceCount :: Lens.Lens' InsightsByAssessment (Prelude.Maybe Prelude.Int)
insightsByAssessment_noncompliantEvidenceCount :: Lens' InsightsByAssessment (Maybe Int)
insightsByAssessment_noncompliantEvidenceCount = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\InsightsByAssessment' {Maybe Int
noncompliantEvidenceCount :: Maybe Int
$sel:noncompliantEvidenceCount:InsightsByAssessment' :: InsightsByAssessment -> Maybe Int
noncompliantEvidenceCount} -> Maybe Int
noncompliantEvidenceCount) (\s :: InsightsByAssessment
s@InsightsByAssessment' {} Maybe Int
a -> InsightsByAssessment
s {$sel:noncompliantEvidenceCount:InsightsByAssessment' :: Maybe Int
noncompliantEvidenceCount = Maybe Int
a} :: InsightsByAssessment)

-- | The total number of controls in the assessment.
insightsByAssessment_totalAssessmentControlsCount :: Lens.Lens' InsightsByAssessment (Prelude.Maybe Prelude.Int)
insightsByAssessment_totalAssessmentControlsCount :: Lens' InsightsByAssessment (Maybe Int)
insightsByAssessment_totalAssessmentControlsCount = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\InsightsByAssessment' {Maybe Int
totalAssessmentControlsCount :: Maybe Int
$sel:totalAssessmentControlsCount:InsightsByAssessment' :: InsightsByAssessment -> Maybe Int
totalAssessmentControlsCount} -> Maybe Int
totalAssessmentControlsCount) (\s :: InsightsByAssessment
s@InsightsByAssessment' {} Maybe Int
a -> InsightsByAssessment
s {$sel:totalAssessmentControlsCount:InsightsByAssessment' :: Maybe Int
totalAssessmentControlsCount = Maybe Int
a} :: InsightsByAssessment)

instance Data.FromJSON InsightsByAssessment where
  parseJSON :: Value -> Parser InsightsByAssessment
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"InsightsByAssessment"
      ( \Object
x ->
          Maybe Int
-> Maybe Int
-> Maybe Int
-> Maybe POSIX
-> Maybe Int
-> Maybe Int
-> InsightsByAssessment
InsightsByAssessment'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ( Object
x
                            forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"assessmentControlsCountByNoncompliantEvidence"
                        )
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"compliantEvidenceCount")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"inconclusiveEvidenceCount")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"lastUpdated")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"noncompliantEvidenceCount")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"totalAssessmentControlsCount")
      )

instance Prelude.Hashable InsightsByAssessment where
  hashWithSalt :: Int -> InsightsByAssessment -> Int
hashWithSalt Int
_salt InsightsByAssessment' {Maybe Int
Maybe POSIX
totalAssessmentControlsCount :: Maybe Int
noncompliantEvidenceCount :: Maybe Int
lastUpdated :: Maybe POSIX
inconclusiveEvidenceCount :: Maybe Int
compliantEvidenceCount :: Maybe Int
assessmentControlsCountByNoncompliantEvidence :: Maybe Int
$sel:totalAssessmentControlsCount:InsightsByAssessment' :: InsightsByAssessment -> Maybe Int
$sel:noncompliantEvidenceCount:InsightsByAssessment' :: InsightsByAssessment -> Maybe Int
$sel:lastUpdated:InsightsByAssessment' :: InsightsByAssessment -> Maybe POSIX
$sel:inconclusiveEvidenceCount:InsightsByAssessment' :: InsightsByAssessment -> Maybe Int
$sel:compliantEvidenceCount:InsightsByAssessment' :: InsightsByAssessment -> Maybe Int
$sel:assessmentControlsCountByNoncompliantEvidence:InsightsByAssessment' :: InsightsByAssessment -> Maybe Int
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Int
assessmentControlsCountByNoncompliantEvidence
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Int
compliantEvidenceCount
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Int
inconclusiveEvidenceCount
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe POSIX
lastUpdated
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Int
noncompliantEvidenceCount
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Int
totalAssessmentControlsCount

instance Prelude.NFData InsightsByAssessment where
  rnf :: InsightsByAssessment -> ()
rnf InsightsByAssessment' {Maybe Int
Maybe POSIX
totalAssessmentControlsCount :: Maybe Int
noncompliantEvidenceCount :: Maybe Int
lastUpdated :: Maybe POSIX
inconclusiveEvidenceCount :: Maybe Int
compliantEvidenceCount :: Maybe Int
assessmentControlsCountByNoncompliantEvidence :: Maybe Int
$sel:totalAssessmentControlsCount:InsightsByAssessment' :: InsightsByAssessment -> Maybe Int
$sel:noncompliantEvidenceCount:InsightsByAssessment' :: InsightsByAssessment -> Maybe Int
$sel:lastUpdated:InsightsByAssessment' :: InsightsByAssessment -> Maybe POSIX
$sel:inconclusiveEvidenceCount:InsightsByAssessment' :: InsightsByAssessment -> Maybe Int
$sel:compliantEvidenceCount:InsightsByAssessment' :: InsightsByAssessment -> Maybe Int
$sel:assessmentControlsCountByNoncompliantEvidence:InsightsByAssessment' :: InsightsByAssessment -> Maybe Int
..} =
    forall a. NFData a => a -> ()
Prelude.rnf
      Maybe Int
assessmentControlsCountByNoncompliantEvidence
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Int
compliantEvidenceCount
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Int
inconclusiveEvidenceCount
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe POSIX
lastUpdated
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Int
noncompliantEvidenceCount
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Int
totalAssessmentControlsCount