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

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
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
(FindingStatistics -> FindingStatistics -> Bool)
-> (FindingStatistics -> FindingStatistics -> Bool)
-> Eq FindingStatistics
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]
(Int -> ReadS FindingStatistics)
-> ReadS [FindingStatistics]
-> ReadPrec FindingStatistics
-> ReadPrec [FindingStatistics]
-> Read 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
(Int -> FindingStatistics -> ShowS)
-> (FindingStatistics -> String)
-> ([FindingStatistics] -> ShowS)
-> Show FindingStatistics
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. FindingStatistics -> Rep FindingStatistics x)
-> (forall x. Rep FindingStatistics x -> FindingStatistics)
-> Generic FindingStatistics
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' :: Maybe (HashMap Text Int) -> FindingStatistics
FindingStatistics'
    { $sel:countBySeverity:FindingStatistics' :: Maybe (HashMap Text Int)
countBySeverity =
        Maybe (HashMap Text Int)
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 :: (Maybe (HashMap Text Int) -> f (Maybe (HashMap Text Int)))
-> FindingStatistics -> f FindingStatistics
findingStatistics_countBySeverity = (FindingStatistics -> Maybe (HashMap Text Int))
-> (FindingStatistics
    -> Maybe (HashMap Text Int) -> FindingStatistics)
-> Lens
     FindingStatistics
     FindingStatistics
     (Maybe (HashMap Text Int))
     (Maybe (HashMap Text Int))
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) ((Maybe (HashMap Text Int) -> f (Maybe (HashMap Text Int)))
 -> FindingStatistics -> f FindingStatistics)
-> ((Maybe (HashMap Text Int) -> f (Maybe (HashMap Text Int)))
    -> Maybe (HashMap Text Int) -> f (Maybe (HashMap Text Int)))
-> (Maybe (HashMap Text Int) -> f (Maybe (HashMap Text Int)))
-> FindingStatistics
-> f FindingStatistics
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  (HashMap Text Int)
  (HashMap Text Int)
  (HashMap Text Int)
  (HashMap Text Int)
-> Iso
     (Maybe (HashMap Text Int))
     (Maybe (HashMap Text Int))
     (Maybe (HashMap Text Int))
     (Maybe (HashMap Text Int))
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 Text Int)
  (HashMap Text Int)
  (HashMap Text Int)
  (HashMap Text Int)
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Core.FromJSON FindingStatistics where
  parseJSON :: Value -> Parser FindingStatistics
parseJSON =
    String
-> (Object -> Parser FindingStatistics)
-> Value
-> Parser FindingStatistics
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"FindingStatistics"
      ( \Object
x ->
          Maybe (HashMap Text Int) -> FindingStatistics
FindingStatistics'
            (Maybe (HashMap Text Int) -> FindingStatistics)
-> Parser (Maybe (HashMap Text Int)) -> Parser FindingStatistics
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ( Object
x Object -> Text -> Parser (Maybe (Maybe (HashMap Text Int)))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"countBySeverity"
                            Parser (Maybe (Maybe (HashMap Text Int)))
-> Maybe (HashMap Text Int) -> Parser (Maybe (HashMap Text Int))
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe (HashMap Text Int)
forall a. Monoid a => a
Prelude.mempty
                        )
      )

instance Prelude.Hashable FindingStatistics

instance Prelude.NFData FindingStatistics