{-# 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.Insights
-- 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.Insights 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 all your active assessments.
--
-- This summary is a snapshot of the data that your active assessments
-- collected on the @lastUpdated@ date. It’s important to understand that
-- the following totals are daily counts based on this date — they aren’t a
-- total sum to date.
--
-- The @Insights@ data is eventually consistent. This means that, when you
-- read data from @Insights@, 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 should return 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:/ 'newInsights' smart constructor.
data Insights = Insights'
  { -- | The number of active assessments in Audit Manager.
    Insights -> Maybe Int
activeAssessmentsCount :: Prelude.Maybe Prelude.Int,
    -- | The number of assessment controls that collected non-compliant evidence
    -- on the @lastUpdated@ date.
    Insights -> Maybe Int
assessmentControlsCountByNoncompliantEvidence :: Prelude.Maybe Prelude.Int,
    -- | The number of compliance check evidence that Audit Manager classified as
    -- compliant on the @lastUpdated@ date. This includes evidence that was
    -- collected from Security Hub with a /Pass/ ruling, or collected from
    -- Config with a /Compliant/ ruling.
    Insights -> Maybe Int
compliantEvidenceCount :: Prelude.Maybe Prelude.Int,
    -- | The number of evidence without a compliance check ruling. Evidence is
    -- inconclusive when the associated control uses Security Hub or Config as
    -- a data source but you didn\'t enable those services. This is also the
    -- case when 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
    -- classed as /inconclusive/ in @Insights@ data.
    Insights -> Maybe Int
inconclusiveEvidenceCount :: Prelude.Maybe Prelude.Int,
    -- | The time when the cross-assessment insights were last updated.
    Insights -> Maybe POSIX
lastUpdated :: Prelude.Maybe Data.POSIX,
    -- | The number of compliance check evidence that Audit Manager classified as
    -- non-compliant on the @lastUpdated@ date. This includes evidence that was
    -- collected from Security Hub with a /Fail/ ruling, or collected from
    -- Config with a /Non-compliant/ ruling.
    Insights -> Maybe Int
noncompliantEvidenceCount :: Prelude.Maybe Prelude.Int,
    -- | The total number of controls across all active assessments.
    Insights -> Maybe Int
totalAssessmentControlsCount :: Prelude.Maybe Prelude.Int
  }
  deriving (Insights -> Insights -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Insights -> Insights -> Bool
$c/= :: Insights -> Insights -> Bool
== :: Insights -> Insights -> Bool
$c== :: Insights -> Insights -> Bool
Prelude.Eq, ReadPrec [Insights]
ReadPrec Insights
Int -> ReadS Insights
ReadS [Insights]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Insights]
$creadListPrec :: ReadPrec [Insights]
readPrec :: ReadPrec Insights
$creadPrec :: ReadPrec Insights
readList :: ReadS [Insights]
$creadList :: ReadS [Insights]
readsPrec :: Int -> ReadS Insights
$creadsPrec :: Int -> ReadS Insights
Prelude.Read, Int -> Insights -> ShowS
[Insights] -> ShowS
Insights -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Insights] -> ShowS
$cshowList :: [Insights] -> ShowS
show :: Insights -> String
$cshow :: Insights -> String
showsPrec :: Int -> Insights -> ShowS
$cshowsPrec :: Int -> Insights -> ShowS
Prelude.Show, forall x. Rep Insights x -> Insights
forall x. Insights -> Rep Insights x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Insights x -> Insights
$cfrom :: forall x. Insights -> Rep Insights x
Prelude.Generic)

-- |
-- Create a value of 'Insights' 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:
--
-- 'activeAssessmentsCount', 'insights_activeAssessmentsCount' - The number of active assessments in Audit Manager.
--
-- 'assessmentControlsCountByNoncompliantEvidence', 'insights_assessmentControlsCountByNoncompliantEvidence' - The number of assessment controls that collected non-compliant evidence
-- on the @lastUpdated@ date.
--
-- 'compliantEvidenceCount', 'insights_compliantEvidenceCount' - The number of compliance check evidence that Audit Manager classified as
-- compliant on the @lastUpdated@ date. This includes evidence that was
-- collected from Security Hub with a /Pass/ ruling, or collected from
-- Config with a /Compliant/ ruling.
--
-- 'inconclusiveEvidenceCount', 'insights_inconclusiveEvidenceCount' - The number of evidence without a compliance check ruling. Evidence is
-- inconclusive when the associated control uses Security Hub or Config as
-- a data source but you didn\'t enable those services. This is also the
-- case when 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
-- classed as /inconclusive/ in @Insights@ data.
--
-- 'lastUpdated', 'insights_lastUpdated' - The time when the cross-assessment insights were last updated.
--
-- 'noncompliantEvidenceCount', 'insights_noncompliantEvidenceCount' - The number of compliance check evidence that Audit Manager classified as
-- non-compliant on the @lastUpdated@ date. This includes evidence that was
-- collected from Security Hub with a /Fail/ ruling, or collected from
-- Config with a /Non-compliant/ ruling.
--
-- 'totalAssessmentControlsCount', 'insights_totalAssessmentControlsCount' - The total number of controls across all active assessments.
newInsights ::
  Insights
newInsights :: Insights
newInsights =
  Insights'
    { $sel:activeAssessmentsCount:Insights' :: Maybe Int
activeAssessmentsCount = forall a. Maybe a
Prelude.Nothing,
      $sel:assessmentControlsCountByNoncompliantEvidence:Insights' :: Maybe Int
assessmentControlsCountByNoncompliantEvidence =
        forall a. Maybe a
Prelude.Nothing,
      $sel:compliantEvidenceCount:Insights' :: Maybe Int
compliantEvidenceCount = forall a. Maybe a
Prelude.Nothing,
      $sel:inconclusiveEvidenceCount:Insights' :: Maybe Int
inconclusiveEvidenceCount = forall a. Maybe a
Prelude.Nothing,
      $sel:lastUpdated:Insights' :: Maybe POSIX
lastUpdated = forall a. Maybe a
Prelude.Nothing,
      $sel:noncompliantEvidenceCount:Insights' :: Maybe Int
noncompliantEvidenceCount = forall a. Maybe a
Prelude.Nothing,
      $sel:totalAssessmentControlsCount:Insights' :: Maybe Int
totalAssessmentControlsCount = forall a. Maybe a
Prelude.Nothing
    }

-- | The number of active assessments in Audit Manager.
insights_activeAssessmentsCount :: Lens.Lens' Insights (Prelude.Maybe Prelude.Int)
insights_activeAssessmentsCount :: Lens' Insights (Maybe Int)
insights_activeAssessmentsCount = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Insights' {Maybe Int
activeAssessmentsCount :: Maybe Int
$sel:activeAssessmentsCount:Insights' :: Insights -> Maybe Int
activeAssessmentsCount} -> Maybe Int
activeAssessmentsCount) (\s :: Insights
s@Insights' {} Maybe Int
a -> Insights
s {$sel:activeAssessmentsCount:Insights' :: Maybe Int
activeAssessmentsCount = Maybe Int
a} :: Insights)

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

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

-- | The number of evidence without a compliance check ruling. Evidence is
-- inconclusive when the associated control uses Security Hub or Config as
-- a data source but you didn\'t enable those services. This is also the
-- case when 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
-- classed as /inconclusive/ in @Insights@ data.
insights_inconclusiveEvidenceCount :: Lens.Lens' Insights (Prelude.Maybe Prelude.Int)
insights_inconclusiveEvidenceCount :: Lens' Insights (Maybe Int)
insights_inconclusiveEvidenceCount = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Insights' {Maybe Int
inconclusiveEvidenceCount :: Maybe Int
$sel:inconclusiveEvidenceCount:Insights' :: Insights -> Maybe Int
inconclusiveEvidenceCount} -> Maybe Int
inconclusiveEvidenceCount) (\s :: Insights
s@Insights' {} Maybe Int
a -> Insights
s {$sel:inconclusiveEvidenceCount:Insights' :: Maybe Int
inconclusiveEvidenceCount = Maybe Int
a} :: Insights)

-- | The time when the cross-assessment insights were last updated.
insights_lastUpdated :: Lens.Lens' Insights (Prelude.Maybe Prelude.UTCTime)
insights_lastUpdated :: Lens' Insights (Maybe UTCTime)
insights_lastUpdated = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Insights' {Maybe POSIX
lastUpdated :: Maybe POSIX
$sel:lastUpdated:Insights' :: Insights -> Maybe POSIX
lastUpdated} -> Maybe POSIX
lastUpdated) (\s :: Insights
s@Insights' {} Maybe POSIX
a -> Insights
s {$sel:lastUpdated:Insights' :: Maybe POSIX
lastUpdated = Maybe POSIX
a} :: Insights) 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 on the @lastUpdated@ date. This includes evidence that was
-- collected from Security Hub with a /Fail/ ruling, or collected from
-- Config with a /Non-compliant/ ruling.
insights_noncompliantEvidenceCount :: Lens.Lens' Insights (Prelude.Maybe Prelude.Int)
insights_noncompliantEvidenceCount :: Lens' Insights (Maybe Int)
insights_noncompliantEvidenceCount = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Insights' {Maybe Int
noncompliantEvidenceCount :: Maybe Int
$sel:noncompliantEvidenceCount:Insights' :: Insights -> Maybe Int
noncompliantEvidenceCount} -> Maybe Int
noncompliantEvidenceCount) (\s :: Insights
s@Insights' {} Maybe Int
a -> Insights
s {$sel:noncompliantEvidenceCount:Insights' :: Maybe Int
noncompliantEvidenceCount = Maybe Int
a} :: Insights)

-- | The total number of controls across all active assessments.
insights_totalAssessmentControlsCount :: Lens.Lens' Insights (Prelude.Maybe Prelude.Int)
insights_totalAssessmentControlsCount :: Lens' Insights (Maybe Int)
insights_totalAssessmentControlsCount = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Insights' {Maybe Int
totalAssessmentControlsCount :: Maybe Int
$sel:totalAssessmentControlsCount:Insights' :: Insights -> Maybe Int
totalAssessmentControlsCount} -> Maybe Int
totalAssessmentControlsCount) (\s :: Insights
s@Insights' {} Maybe Int
a -> Insights
s {$sel:totalAssessmentControlsCount:Insights' :: Maybe Int
totalAssessmentControlsCount = Maybe Int
a} :: Insights)

instance Data.FromJSON Insights where
  parseJSON :: Value -> Parser Insights
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"Insights"
      ( \Object
x ->
          Maybe Int
-> Maybe Int
-> Maybe Int
-> Maybe Int
-> Maybe POSIX
-> Maybe Int
-> Maybe Int
-> Insights
Insights'
            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
"activeAssessmentsCount")
            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
"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 Insights where
  hashWithSalt :: Int -> Insights -> Int
hashWithSalt Int
_salt Insights' {Maybe Int
Maybe POSIX
totalAssessmentControlsCount :: Maybe Int
noncompliantEvidenceCount :: Maybe Int
lastUpdated :: Maybe POSIX
inconclusiveEvidenceCount :: Maybe Int
compliantEvidenceCount :: Maybe Int
assessmentControlsCountByNoncompliantEvidence :: Maybe Int
activeAssessmentsCount :: Maybe Int
$sel:totalAssessmentControlsCount:Insights' :: Insights -> Maybe Int
$sel:noncompliantEvidenceCount:Insights' :: Insights -> Maybe Int
$sel:lastUpdated:Insights' :: Insights -> Maybe POSIX
$sel:inconclusiveEvidenceCount:Insights' :: Insights -> Maybe Int
$sel:compliantEvidenceCount:Insights' :: Insights -> Maybe Int
$sel:assessmentControlsCountByNoncompliantEvidence:Insights' :: Insights -> Maybe Int
$sel:activeAssessmentsCount:Insights' :: Insights -> Maybe Int
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Int
activeAssessmentsCount
      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 Insights where
  rnf :: Insights -> ()
rnf Insights' {Maybe Int
Maybe POSIX
totalAssessmentControlsCount :: Maybe Int
noncompliantEvidenceCount :: Maybe Int
lastUpdated :: Maybe POSIX
inconclusiveEvidenceCount :: Maybe Int
compliantEvidenceCount :: Maybe Int
assessmentControlsCountByNoncompliantEvidence :: Maybe Int
activeAssessmentsCount :: Maybe Int
$sel:totalAssessmentControlsCount:Insights' :: Insights -> Maybe Int
$sel:noncompliantEvidenceCount:Insights' :: Insights -> Maybe Int
$sel:lastUpdated:Insights' :: Insights -> Maybe POSIX
$sel:inconclusiveEvidenceCount:Insights' :: Insights -> Maybe Int
$sel:compliantEvidenceCount:Insights' :: Insights -> Maybe Int
$sel:assessmentControlsCountByNoncompliantEvidence:Insights' :: Insights -> Maybe Int
$sel:activeAssessmentsCount:Insights' :: Insights -> Maybe Int
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Int
activeAssessmentsCount
      seq :: forall a b. a -> b -> b
`Prelude.seq` 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