{-# 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.SecurityHub.Types.SensitiveDataResult
-- 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.SecurityHub.Types.SensitiveDataResult where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import Amazonka.SecurityHub.Types.SensitiveDataDetections

-- | Contains a detected instance of sensitive data that are based on
-- built-in identifiers.
--
-- /See:/ 'newSensitiveDataResult' smart constructor.
data SensitiveDataResult = SensitiveDataResult'
  { -- | The list of detected instances of sensitive data.
    SensitiveDataResult -> Maybe [SensitiveDataDetections]
detections :: Prelude.Maybe [SensitiveDataDetections],
    -- | The category of sensitive data that was detected. For example, the
    -- category can indicate that the sensitive data involved credentials,
    -- financial information, or personal information.
    SensitiveDataResult -> Maybe Text
category :: Prelude.Maybe Prelude.Text,
    -- | The total number of occurrences of sensitive data.
    SensitiveDataResult -> Maybe Integer
totalCount :: Prelude.Maybe Prelude.Integer
  }
  deriving (SensitiveDataResult -> SensitiveDataResult -> Bool
(SensitiveDataResult -> SensitiveDataResult -> Bool)
-> (SensitiveDataResult -> SensitiveDataResult -> Bool)
-> Eq SensitiveDataResult
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SensitiveDataResult -> SensitiveDataResult -> Bool
$c/= :: SensitiveDataResult -> SensitiveDataResult -> Bool
== :: SensitiveDataResult -> SensitiveDataResult -> Bool
$c== :: SensitiveDataResult -> SensitiveDataResult -> Bool
Prelude.Eq, ReadPrec [SensitiveDataResult]
ReadPrec SensitiveDataResult
Int -> ReadS SensitiveDataResult
ReadS [SensitiveDataResult]
(Int -> ReadS SensitiveDataResult)
-> ReadS [SensitiveDataResult]
-> ReadPrec SensitiveDataResult
-> ReadPrec [SensitiveDataResult]
-> Read SensitiveDataResult
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [SensitiveDataResult]
$creadListPrec :: ReadPrec [SensitiveDataResult]
readPrec :: ReadPrec SensitiveDataResult
$creadPrec :: ReadPrec SensitiveDataResult
readList :: ReadS [SensitiveDataResult]
$creadList :: ReadS [SensitiveDataResult]
readsPrec :: Int -> ReadS SensitiveDataResult
$creadsPrec :: Int -> ReadS SensitiveDataResult
Prelude.Read, Int -> SensitiveDataResult -> ShowS
[SensitiveDataResult] -> ShowS
SensitiveDataResult -> String
(Int -> SensitiveDataResult -> ShowS)
-> (SensitiveDataResult -> String)
-> ([SensitiveDataResult] -> ShowS)
-> Show SensitiveDataResult
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SensitiveDataResult] -> ShowS
$cshowList :: [SensitiveDataResult] -> ShowS
show :: SensitiveDataResult -> String
$cshow :: SensitiveDataResult -> String
showsPrec :: Int -> SensitiveDataResult -> ShowS
$cshowsPrec :: Int -> SensitiveDataResult -> ShowS
Prelude.Show, (forall x. SensitiveDataResult -> Rep SensitiveDataResult x)
-> (forall x. Rep SensitiveDataResult x -> SensitiveDataResult)
-> Generic SensitiveDataResult
forall x. Rep SensitiveDataResult x -> SensitiveDataResult
forall x. SensitiveDataResult -> Rep SensitiveDataResult x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep SensitiveDataResult x -> SensitiveDataResult
$cfrom :: forall x. SensitiveDataResult -> Rep SensitiveDataResult x
Prelude.Generic)

-- |
-- Create a value of 'SensitiveDataResult' 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:
--
-- 'detections', 'sensitiveDataResult_detections' - The list of detected instances of sensitive data.
--
-- 'category', 'sensitiveDataResult_category' - The category of sensitive data that was detected. For example, the
-- category can indicate that the sensitive data involved credentials,
-- financial information, or personal information.
--
-- 'totalCount', 'sensitiveDataResult_totalCount' - The total number of occurrences of sensitive data.
newSensitiveDataResult ::
  SensitiveDataResult
newSensitiveDataResult :: SensitiveDataResult
newSensitiveDataResult =
  SensitiveDataResult' :: Maybe [SensitiveDataDetections]
-> Maybe Text -> Maybe Integer -> SensitiveDataResult
SensitiveDataResult'
    { $sel:detections:SensitiveDataResult' :: Maybe [SensitiveDataDetections]
detections = Maybe [SensitiveDataDetections]
forall a. Maybe a
Prelude.Nothing,
      $sel:category:SensitiveDataResult' :: Maybe Text
category = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:totalCount:SensitiveDataResult' :: Maybe Integer
totalCount = Maybe Integer
forall a. Maybe a
Prelude.Nothing
    }

-- | The list of detected instances of sensitive data.
sensitiveDataResult_detections :: Lens.Lens' SensitiveDataResult (Prelude.Maybe [SensitiveDataDetections])
sensitiveDataResult_detections :: (Maybe [SensitiveDataDetections]
 -> f (Maybe [SensitiveDataDetections]))
-> SensitiveDataResult -> f SensitiveDataResult
sensitiveDataResult_detections = (SensitiveDataResult -> Maybe [SensitiveDataDetections])
-> (SensitiveDataResult
    -> Maybe [SensitiveDataDetections] -> SensitiveDataResult)
-> Lens
     SensitiveDataResult
     SensitiveDataResult
     (Maybe [SensitiveDataDetections])
     (Maybe [SensitiveDataDetections])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SensitiveDataResult' {Maybe [SensitiveDataDetections]
detections :: Maybe [SensitiveDataDetections]
$sel:detections:SensitiveDataResult' :: SensitiveDataResult -> Maybe [SensitiveDataDetections]
detections} -> Maybe [SensitiveDataDetections]
detections) (\s :: SensitiveDataResult
s@SensitiveDataResult' {} Maybe [SensitiveDataDetections]
a -> SensitiveDataResult
s {$sel:detections:SensitiveDataResult' :: Maybe [SensitiveDataDetections]
detections = Maybe [SensitiveDataDetections]
a} :: SensitiveDataResult) ((Maybe [SensitiveDataDetections]
  -> f (Maybe [SensitiveDataDetections]))
 -> SensitiveDataResult -> f SensitiveDataResult)
-> ((Maybe [SensitiveDataDetections]
     -> f (Maybe [SensitiveDataDetections]))
    -> Maybe [SensitiveDataDetections]
    -> f (Maybe [SensitiveDataDetections]))
-> (Maybe [SensitiveDataDetections]
    -> f (Maybe [SensitiveDataDetections]))
-> SensitiveDataResult
-> f SensitiveDataResult
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  [SensitiveDataDetections]
  [SensitiveDataDetections]
  [SensitiveDataDetections]
  [SensitiveDataDetections]
-> Iso
     (Maybe [SensitiveDataDetections])
     (Maybe [SensitiveDataDetections])
     (Maybe [SensitiveDataDetections])
     (Maybe [SensitiveDataDetections])
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
  [SensitiveDataDetections]
  [SensitiveDataDetections]
  [SensitiveDataDetections]
  [SensitiveDataDetections]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The category of sensitive data that was detected. For example, the
-- category can indicate that the sensitive data involved credentials,
-- financial information, or personal information.
sensitiveDataResult_category :: Lens.Lens' SensitiveDataResult (Prelude.Maybe Prelude.Text)
sensitiveDataResult_category :: (Maybe Text -> f (Maybe Text))
-> SensitiveDataResult -> f SensitiveDataResult
sensitiveDataResult_category = (SensitiveDataResult -> Maybe Text)
-> (SensitiveDataResult -> Maybe Text -> SensitiveDataResult)
-> Lens
     SensitiveDataResult SensitiveDataResult (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SensitiveDataResult' {Maybe Text
category :: Maybe Text
$sel:category:SensitiveDataResult' :: SensitiveDataResult -> Maybe Text
category} -> Maybe Text
category) (\s :: SensitiveDataResult
s@SensitiveDataResult' {} Maybe Text
a -> SensitiveDataResult
s {$sel:category:SensitiveDataResult' :: Maybe Text
category = Maybe Text
a} :: SensitiveDataResult)

-- | The total number of occurrences of sensitive data.
sensitiveDataResult_totalCount :: Lens.Lens' SensitiveDataResult (Prelude.Maybe Prelude.Integer)
sensitiveDataResult_totalCount :: (Maybe Integer -> f (Maybe Integer))
-> SensitiveDataResult -> f SensitiveDataResult
sensitiveDataResult_totalCount = (SensitiveDataResult -> Maybe Integer)
-> (SensitiveDataResult -> Maybe Integer -> SensitiveDataResult)
-> Lens
     SensitiveDataResult
     SensitiveDataResult
     (Maybe Integer)
     (Maybe Integer)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SensitiveDataResult' {Maybe Integer
totalCount :: Maybe Integer
$sel:totalCount:SensitiveDataResult' :: SensitiveDataResult -> Maybe Integer
totalCount} -> Maybe Integer
totalCount) (\s :: SensitiveDataResult
s@SensitiveDataResult' {} Maybe Integer
a -> SensitiveDataResult
s {$sel:totalCount:SensitiveDataResult' :: Maybe Integer
totalCount = Maybe Integer
a} :: SensitiveDataResult)

instance Core.FromJSON SensitiveDataResult where
  parseJSON :: Value -> Parser SensitiveDataResult
parseJSON =
    String
-> (Object -> Parser SensitiveDataResult)
-> Value
-> Parser SensitiveDataResult
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"SensitiveDataResult"
      ( \Object
x ->
          Maybe [SensitiveDataDetections]
-> Maybe Text -> Maybe Integer -> SensitiveDataResult
SensitiveDataResult'
            (Maybe [SensitiveDataDetections]
 -> Maybe Text -> Maybe Integer -> SensitiveDataResult)
-> Parser (Maybe [SensitiveDataDetections])
-> Parser (Maybe Text -> Maybe Integer -> SensitiveDataResult)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe (Maybe [SensitiveDataDetections]))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Detections" Parser (Maybe (Maybe [SensitiveDataDetections]))
-> Maybe [SensitiveDataDetections]
-> Parser (Maybe [SensitiveDataDetections])
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe [SensitiveDataDetections]
forall a. Monoid a => a
Prelude.mempty)
            Parser (Maybe Text -> Maybe Integer -> SensitiveDataResult)
-> Parser (Maybe Text)
-> Parser (Maybe Integer -> SensitiveDataResult)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Category")
            Parser (Maybe Integer -> SensitiveDataResult)
-> Parser (Maybe Integer) -> Parser SensitiveDataResult
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Integer)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"TotalCount")
      )

instance Prelude.Hashable SensitiveDataResult

instance Prelude.NFData SensitiveDataResult

instance Core.ToJSON SensitiveDataResult where
  toJSON :: SensitiveDataResult -> Value
toJSON SensitiveDataResult' {Maybe Integer
Maybe [SensitiveDataDetections]
Maybe Text
totalCount :: Maybe Integer
category :: Maybe Text
detections :: Maybe [SensitiveDataDetections]
$sel:totalCount:SensitiveDataResult' :: SensitiveDataResult -> Maybe Integer
$sel:category:SensitiveDataResult' :: SensitiveDataResult -> Maybe Text
$sel:detections:SensitiveDataResult' :: SensitiveDataResult -> Maybe [SensitiveDataDetections]
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"Detections" Text -> [SensitiveDataDetections] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) ([SensitiveDataDetections] -> Pair)
-> Maybe [SensitiveDataDetections] -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [SensitiveDataDetections]
detections,
            (Text
"Category" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
category,
            (Text
"TotalCount" Text -> Integer -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Integer -> Pair) -> Maybe Integer -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Integer
totalCount
          ]
      )