{-# 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.GuardDuty.Types.FindingStatistics
-- 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.GuardDuty.Types.FindingStatistics 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

-- | Contains information about finding statistics.
--
-- /See:/ 'newFindingStatistics' smart constructor.
data FindingStatistics = FindingStatistics'
  { -- | Represents a map of severity to count statistics for a set of findings.
    FindingStatistics -> Maybe (HashMap Text Int)
countBySeverity :: Prelude.Maybe (Prelude.HashMap Prelude.Text Prelude.Int)
  }
  deriving (FindingStatistics -> FindingStatistics -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: FindingStatistics -> FindingStatistics -> Bool
$c/= :: FindingStatistics -> FindingStatistics -> Bool
== :: FindingStatistics -> FindingStatistics -> Bool
$c== :: FindingStatistics -> FindingStatistics -> Bool
Prelude.Eq, ReadPrec [FindingStatistics]
ReadPrec FindingStatistics
Int -> ReadS FindingStatistics
ReadS [FindingStatistics]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [FindingStatistics]
$creadListPrec :: ReadPrec [FindingStatistics]
readPrec :: ReadPrec FindingStatistics
$creadPrec :: ReadPrec FindingStatistics
readList :: ReadS [FindingStatistics]
$creadList :: ReadS [FindingStatistics]
readsPrec :: Int -> ReadS FindingStatistics
$creadsPrec :: Int -> ReadS FindingStatistics
Prelude.Read, Int -> FindingStatistics -> ShowS
[FindingStatistics] -> ShowS
FindingStatistics -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [FindingStatistics] -> ShowS
$cshowList :: [FindingStatistics] -> ShowS
show :: FindingStatistics -> String
$cshow :: FindingStatistics -> String
showsPrec :: Int -> FindingStatistics -> ShowS
$cshowsPrec :: Int -> FindingStatistics -> ShowS
Prelude.Show, forall x. Rep FindingStatistics x -> FindingStatistics
forall x. FindingStatistics -> Rep FindingStatistics x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep FindingStatistics x -> FindingStatistics
$cfrom :: forall x. FindingStatistics -> Rep FindingStatistics x
Prelude.Generic)

-- |
-- Create a value of 'FindingStatistics' 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:
--
-- 'countBySeverity', 'findingStatistics_countBySeverity' - Represents a map of severity to count statistics for a set of findings.
newFindingStatistics ::
  FindingStatistics
newFindingStatistics :: FindingStatistics
newFindingStatistics =
  FindingStatistics'
    { $sel:countBySeverity:FindingStatistics' :: Maybe (HashMap Text Int)
countBySeverity =
        forall a. Maybe a
Prelude.Nothing
    }

-- | Represents a map of severity to count statistics for a set of findings.
findingStatistics_countBySeverity :: Lens.Lens' FindingStatistics (Prelude.Maybe (Prelude.HashMap Prelude.Text Prelude.Int))
findingStatistics_countBySeverity :: Lens' FindingStatistics (Maybe (HashMap Text Int))
findingStatistics_countBySeverity = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\FindingStatistics' {Maybe (HashMap Text Int)
countBySeverity :: Maybe (HashMap Text Int)
$sel:countBySeverity:FindingStatistics' :: FindingStatistics -> Maybe (HashMap Text Int)
countBySeverity} -> Maybe (HashMap Text Int)
countBySeverity) (\s :: FindingStatistics
s@FindingStatistics' {} Maybe (HashMap Text Int)
a -> FindingStatistics
s {$sel:countBySeverity:FindingStatistics' :: Maybe (HashMap Text Int)
countBySeverity = Maybe (HashMap Text Int)
a} :: FindingStatistics) 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 s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Data.FromJSON FindingStatistics where
  parseJSON :: Value -> Parser FindingStatistics
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"FindingStatistics"
      ( \Object
x ->
          Maybe (HashMap Text Int) -> FindingStatistics
FindingStatistics'
            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
"countBySeverity"
                            forall a. Parser (Maybe a) -> a -> Parser a
Data..!= forall a. Monoid a => a
Prelude.mempty
                        )
      )

instance Prelude.Hashable FindingStatistics where
  hashWithSalt :: Int -> FindingStatistics -> Int
hashWithSalt Int
_salt FindingStatistics' {Maybe (HashMap Text Int)
countBySeverity :: Maybe (HashMap Text Int)
$sel:countBySeverity:FindingStatistics' :: FindingStatistics -> Maybe (HashMap Text Int)
..} =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe (HashMap Text Int)
countBySeverity

instance Prelude.NFData FindingStatistics where
  rnf :: FindingStatistics -> ()
rnf FindingStatistics' {Maybe (HashMap Text Int)
countBySeverity :: Maybe (HashMap Text Int)
$sel:countBySeverity:FindingStatistics' :: FindingStatistics -> Maybe (HashMap Text Int)
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe (HashMap Text Int)
countBySeverity