{-# 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.SensitiveDataDetections
-- 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.SensitiveDataDetections where

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

-- | The list of detected instances of sensitive data.
--
-- /See:/ 'newSensitiveDataDetections' smart constructor.
data SensitiveDataDetections = SensitiveDataDetections'
  { -- | Details about the sensitive data that was detected.
    SensitiveDataDetections -> Maybe Occurrences
occurrences :: Prelude.Maybe Occurrences,
    -- | The total number of occurrences of sensitive data that were detected.
    SensitiveDataDetections -> Maybe Integer
count :: Prelude.Maybe Prelude.Integer,
    -- | The type of sensitive data that was detected. For example, the type
    -- might indicate that the data is an email address.
    SensitiveDataDetections -> Maybe Text
type' :: Prelude.Maybe Prelude.Text
  }
  deriving (SensitiveDataDetections -> SensitiveDataDetections -> Bool
(SensitiveDataDetections -> SensitiveDataDetections -> Bool)
-> (SensitiveDataDetections -> SensitiveDataDetections -> Bool)
-> Eq SensitiveDataDetections
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SensitiveDataDetections -> SensitiveDataDetections -> Bool
$c/= :: SensitiveDataDetections -> SensitiveDataDetections -> Bool
== :: SensitiveDataDetections -> SensitiveDataDetections -> Bool
$c== :: SensitiveDataDetections -> SensitiveDataDetections -> Bool
Prelude.Eq, ReadPrec [SensitiveDataDetections]
ReadPrec SensitiveDataDetections
Int -> ReadS SensitiveDataDetections
ReadS [SensitiveDataDetections]
(Int -> ReadS SensitiveDataDetections)
-> ReadS [SensitiveDataDetections]
-> ReadPrec SensitiveDataDetections
-> ReadPrec [SensitiveDataDetections]
-> Read SensitiveDataDetections
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [SensitiveDataDetections]
$creadListPrec :: ReadPrec [SensitiveDataDetections]
readPrec :: ReadPrec SensitiveDataDetections
$creadPrec :: ReadPrec SensitiveDataDetections
readList :: ReadS [SensitiveDataDetections]
$creadList :: ReadS [SensitiveDataDetections]
readsPrec :: Int -> ReadS SensitiveDataDetections
$creadsPrec :: Int -> ReadS SensitiveDataDetections
Prelude.Read, Int -> SensitiveDataDetections -> ShowS
[SensitiveDataDetections] -> ShowS
SensitiveDataDetections -> String
(Int -> SensitiveDataDetections -> ShowS)
-> (SensitiveDataDetections -> String)
-> ([SensitiveDataDetections] -> ShowS)
-> Show SensitiveDataDetections
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SensitiveDataDetections] -> ShowS
$cshowList :: [SensitiveDataDetections] -> ShowS
show :: SensitiveDataDetections -> String
$cshow :: SensitiveDataDetections -> String
showsPrec :: Int -> SensitiveDataDetections -> ShowS
$cshowsPrec :: Int -> SensitiveDataDetections -> ShowS
Prelude.Show, (forall x.
 SensitiveDataDetections -> Rep SensitiveDataDetections x)
-> (forall x.
    Rep SensitiveDataDetections x -> SensitiveDataDetections)
-> Generic SensitiveDataDetections
forall x. Rep SensitiveDataDetections x -> SensitiveDataDetections
forall x. SensitiveDataDetections -> Rep SensitiveDataDetections x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep SensitiveDataDetections x -> SensitiveDataDetections
$cfrom :: forall x. SensitiveDataDetections -> Rep SensitiveDataDetections x
Prelude.Generic)

-- |
-- Create a value of 'SensitiveDataDetections' 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:
--
-- 'occurrences', 'sensitiveDataDetections_occurrences' - Details about the sensitive data that was detected.
--
-- 'count', 'sensitiveDataDetections_count' - The total number of occurrences of sensitive data that were detected.
--
-- 'type'', 'sensitiveDataDetections_type' - The type of sensitive data that was detected. For example, the type
-- might indicate that the data is an email address.
newSensitiveDataDetections ::
  SensitiveDataDetections
newSensitiveDataDetections :: SensitiveDataDetections
newSensitiveDataDetections =
  SensitiveDataDetections' :: Maybe Occurrences
-> Maybe Integer -> Maybe Text -> SensitiveDataDetections
SensitiveDataDetections'
    { $sel:occurrences:SensitiveDataDetections' :: Maybe Occurrences
occurrences =
        Maybe Occurrences
forall a. Maybe a
Prelude.Nothing,
      $sel:count:SensitiveDataDetections' :: Maybe Integer
count = Maybe Integer
forall a. Maybe a
Prelude.Nothing,
      $sel:type':SensitiveDataDetections' :: Maybe Text
type' = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | Details about the sensitive data that was detected.
sensitiveDataDetections_occurrences :: Lens.Lens' SensitiveDataDetections (Prelude.Maybe Occurrences)
sensitiveDataDetections_occurrences :: (Maybe Occurrences -> f (Maybe Occurrences))
-> SensitiveDataDetections -> f SensitiveDataDetections
sensitiveDataDetections_occurrences = (SensitiveDataDetections -> Maybe Occurrences)
-> (SensitiveDataDetections
    -> Maybe Occurrences -> SensitiveDataDetections)
-> Lens
     SensitiveDataDetections
     SensitiveDataDetections
     (Maybe Occurrences)
     (Maybe Occurrences)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SensitiveDataDetections' {Maybe Occurrences
occurrences :: Maybe Occurrences
$sel:occurrences:SensitiveDataDetections' :: SensitiveDataDetections -> Maybe Occurrences
occurrences} -> Maybe Occurrences
occurrences) (\s :: SensitiveDataDetections
s@SensitiveDataDetections' {} Maybe Occurrences
a -> SensitiveDataDetections
s {$sel:occurrences:SensitiveDataDetections' :: Maybe Occurrences
occurrences = Maybe Occurrences
a} :: SensitiveDataDetections)

-- | The total number of occurrences of sensitive data that were detected.
sensitiveDataDetections_count :: Lens.Lens' SensitiveDataDetections (Prelude.Maybe Prelude.Integer)
sensitiveDataDetections_count :: (Maybe Integer -> f (Maybe Integer))
-> SensitiveDataDetections -> f SensitiveDataDetections
sensitiveDataDetections_count = (SensitiveDataDetections -> Maybe Integer)
-> (SensitiveDataDetections
    -> Maybe Integer -> SensitiveDataDetections)
-> Lens
     SensitiveDataDetections
     SensitiveDataDetections
     (Maybe Integer)
     (Maybe Integer)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SensitiveDataDetections' {Maybe Integer
count :: Maybe Integer
$sel:count:SensitiveDataDetections' :: SensitiveDataDetections -> Maybe Integer
count} -> Maybe Integer
count) (\s :: SensitiveDataDetections
s@SensitiveDataDetections' {} Maybe Integer
a -> SensitiveDataDetections
s {$sel:count:SensitiveDataDetections' :: Maybe Integer
count = Maybe Integer
a} :: SensitiveDataDetections)

-- | The type of sensitive data that was detected. For example, the type
-- might indicate that the data is an email address.
sensitiveDataDetections_type :: Lens.Lens' SensitiveDataDetections (Prelude.Maybe Prelude.Text)
sensitiveDataDetections_type :: (Maybe Text -> f (Maybe Text))
-> SensitiveDataDetections -> f SensitiveDataDetections
sensitiveDataDetections_type = (SensitiveDataDetections -> Maybe Text)
-> (SensitiveDataDetections
    -> Maybe Text -> SensitiveDataDetections)
-> Lens
     SensitiveDataDetections
     SensitiveDataDetections
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SensitiveDataDetections' {Maybe Text
type' :: Maybe Text
$sel:type':SensitiveDataDetections' :: SensitiveDataDetections -> Maybe Text
type'} -> Maybe Text
type') (\s :: SensitiveDataDetections
s@SensitiveDataDetections' {} Maybe Text
a -> SensitiveDataDetections
s {$sel:type':SensitiveDataDetections' :: Maybe Text
type' = Maybe Text
a} :: SensitiveDataDetections)

instance Core.FromJSON SensitiveDataDetections where
  parseJSON :: Value -> Parser SensitiveDataDetections
parseJSON =
    String
-> (Object -> Parser SensitiveDataDetections)
-> Value
-> Parser SensitiveDataDetections
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"SensitiveDataDetections"
      ( \Object
x ->
          Maybe Occurrences
-> Maybe Integer -> Maybe Text -> SensitiveDataDetections
SensitiveDataDetections'
            (Maybe Occurrences
 -> Maybe Integer -> Maybe Text -> SensitiveDataDetections)
-> Parser (Maybe Occurrences)
-> Parser (Maybe Integer -> Maybe Text -> SensitiveDataDetections)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe Occurrences)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Occurrences")
            Parser (Maybe Integer -> Maybe Text -> SensitiveDataDetections)
-> Parser (Maybe Integer)
-> Parser (Maybe Text -> SensitiveDataDetections)
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
"Count")
            Parser (Maybe Text -> SensitiveDataDetections)
-> Parser (Maybe Text) -> Parser SensitiveDataDetections
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
"Type")
      )

instance Prelude.Hashable SensitiveDataDetections

instance Prelude.NFData SensitiveDataDetections

instance Core.ToJSON SensitiveDataDetections where
  toJSON :: SensitiveDataDetections -> Value
toJSON SensitiveDataDetections' {Maybe Integer
Maybe Text
Maybe Occurrences
type' :: Maybe Text
count :: Maybe Integer
occurrences :: Maybe Occurrences
$sel:type':SensitiveDataDetections' :: SensitiveDataDetections -> Maybe Text
$sel:count:SensitiveDataDetections' :: SensitiveDataDetections -> Maybe Integer
$sel:occurrences:SensitiveDataDetections' :: SensitiveDataDetections -> Maybe Occurrences
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"Occurrences" Text -> Occurrences -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Occurrences -> Pair) -> Maybe Occurrences -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Occurrences
occurrences,
            (Text
"Count" 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
count,
            (Text
"Type" 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
type'
          ]
      )