{-# 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.MacieV2.Types.SensitiveDataItem
-- 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.MacieV2.Types.SensitiveDataItem where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import Amazonka.MacieV2.Types.DefaultDetection
import Amazonka.MacieV2.Types.SensitiveDataItemCategory
import qualified Amazonka.Prelude as Prelude

-- | Provides information about the category, types, and occurrences of
-- sensitive data that produced a sensitive data finding.
--
-- /See:/ 'newSensitiveDataItem' smart constructor.
data SensitiveDataItem = SensitiveDataItem'
  { -- | An array of objects, one for each type of sensitive data that was
    -- detected. Each object reports the number of occurrences of a specific
    -- type of sensitive data that was detected, and the location of up to 15
    -- of those occurrences.
    SensitiveDataItem -> Maybe [DefaultDetection]
detections :: Prelude.Maybe [DefaultDetection],
    -- | The category of sensitive data that was detected. For example:
    -- CREDENTIALS, for credentials data such as private keys or Amazon Web
    -- Services secret keys; FINANCIAL_INFORMATION, for financial data such as
    -- credit card numbers; or, PERSONAL_INFORMATION, for personal health
    -- information, such as health insurance identification numbers, or
    -- personally identifiable information, such as passport numbers.
    SensitiveDataItem -> Maybe SensitiveDataItemCategory
category :: Prelude.Maybe SensitiveDataItemCategory,
    -- | The total number of occurrences of the sensitive data that was detected.
    SensitiveDataItem -> Maybe Integer
totalCount :: Prelude.Maybe Prelude.Integer
  }
  deriving (SensitiveDataItem -> SensitiveDataItem -> Bool
(SensitiveDataItem -> SensitiveDataItem -> Bool)
-> (SensitiveDataItem -> SensitiveDataItem -> Bool)
-> Eq SensitiveDataItem
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SensitiveDataItem -> SensitiveDataItem -> Bool
$c/= :: SensitiveDataItem -> SensitiveDataItem -> Bool
== :: SensitiveDataItem -> SensitiveDataItem -> Bool
$c== :: SensitiveDataItem -> SensitiveDataItem -> Bool
Prelude.Eq, ReadPrec [SensitiveDataItem]
ReadPrec SensitiveDataItem
Int -> ReadS SensitiveDataItem
ReadS [SensitiveDataItem]
(Int -> ReadS SensitiveDataItem)
-> ReadS [SensitiveDataItem]
-> ReadPrec SensitiveDataItem
-> ReadPrec [SensitiveDataItem]
-> Read SensitiveDataItem
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [SensitiveDataItem]
$creadListPrec :: ReadPrec [SensitiveDataItem]
readPrec :: ReadPrec SensitiveDataItem
$creadPrec :: ReadPrec SensitiveDataItem
readList :: ReadS [SensitiveDataItem]
$creadList :: ReadS [SensitiveDataItem]
readsPrec :: Int -> ReadS SensitiveDataItem
$creadsPrec :: Int -> ReadS SensitiveDataItem
Prelude.Read, Int -> SensitiveDataItem -> ShowS
[SensitiveDataItem] -> ShowS
SensitiveDataItem -> String
(Int -> SensitiveDataItem -> ShowS)
-> (SensitiveDataItem -> String)
-> ([SensitiveDataItem] -> ShowS)
-> Show SensitiveDataItem
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SensitiveDataItem] -> ShowS
$cshowList :: [SensitiveDataItem] -> ShowS
show :: SensitiveDataItem -> String
$cshow :: SensitiveDataItem -> String
showsPrec :: Int -> SensitiveDataItem -> ShowS
$cshowsPrec :: Int -> SensitiveDataItem -> ShowS
Prelude.Show, (forall x. SensitiveDataItem -> Rep SensitiveDataItem x)
-> (forall x. Rep SensitiveDataItem x -> SensitiveDataItem)
-> Generic SensitiveDataItem
forall x. Rep SensitiveDataItem x -> SensitiveDataItem
forall x. SensitiveDataItem -> Rep SensitiveDataItem x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep SensitiveDataItem x -> SensitiveDataItem
$cfrom :: forall x. SensitiveDataItem -> Rep SensitiveDataItem x
Prelude.Generic)

-- |
-- Create a value of 'SensitiveDataItem' 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', 'sensitiveDataItem_detections' - An array of objects, one for each type of sensitive data that was
-- detected. Each object reports the number of occurrences of a specific
-- type of sensitive data that was detected, and the location of up to 15
-- of those occurrences.
--
-- 'category', 'sensitiveDataItem_category' - The category of sensitive data that was detected. For example:
-- CREDENTIALS, for credentials data such as private keys or Amazon Web
-- Services secret keys; FINANCIAL_INFORMATION, for financial data such as
-- credit card numbers; or, PERSONAL_INFORMATION, for personal health
-- information, such as health insurance identification numbers, or
-- personally identifiable information, such as passport numbers.
--
-- 'totalCount', 'sensitiveDataItem_totalCount' - The total number of occurrences of the sensitive data that was detected.
newSensitiveDataItem ::
  SensitiveDataItem
newSensitiveDataItem :: SensitiveDataItem
newSensitiveDataItem =
  SensitiveDataItem' :: Maybe [DefaultDetection]
-> Maybe SensitiveDataItemCategory
-> Maybe Integer
-> SensitiveDataItem
SensitiveDataItem'
    { $sel:detections:SensitiveDataItem' :: Maybe [DefaultDetection]
detections = Maybe [DefaultDetection]
forall a. Maybe a
Prelude.Nothing,
      $sel:category:SensitiveDataItem' :: Maybe SensitiveDataItemCategory
category = Maybe SensitiveDataItemCategory
forall a. Maybe a
Prelude.Nothing,
      $sel:totalCount:SensitiveDataItem' :: Maybe Integer
totalCount = Maybe Integer
forall a. Maybe a
Prelude.Nothing
    }

-- | An array of objects, one for each type of sensitive data that was
-- detected. Each object reports the number of occurrences of a specific
-- type of sensitive data that was detected, and the location of up to 15
-- of those occurrences.
sensitiveDataItem_detections :: Lens.Lens' SensitiveDataItem (Prelude.Maybe [DefaultDetection])
sensitiveDataItem_detections :: (Maybe [DefaultDetection] -> f (Maybe [DefaultDetection]))
-> SensitiveDataItem -> f SensitiveDataItem
sensitiveDataItem_detections = (SensitiveDataItem -> Maybe [DefaultDetection])
-> (SensitiveDataItem
    -> Maybe [DefaultDetection] -> SensitiveDataItem)
-> Lens
     SensitiveDataItem
     SensitiveDataItem
     (Maybe [DefaultDetection])
     (Maybe [DefaultDetection])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SensitiveDataItem' {Maybe [DefaultDetection]
detections :: Maybe [DefaultDetection]
$sel:detections:SensitiveDataItem' :: SensitiveDataItem -> Maybe [DefaultDetection]
detections} -> Maybe [DefaultDetection]
detections) (\s :: SensitiveDataItem
s@SensitiveDataItem' {} Maybe [DefaultDetection]
a -> SensitiveDataItem
s {$sel:detections:SensitiveDataItem' :: Maybe [DefaultDetection]
detections = Maybe [DefaultDetection]
a} :: SensitiveDataItem) ((Maybe [DefaultDetection] -> f (Maybe [DefaultDetection]))
 -> SensitiveDataItem -> f SensitiveDataItem)
-> ((Maybe [DefaultDetection] -> f (Maybe [DefaultDetection]))
    -> Maybe [DefaultDetection] -> f (Maybe [DefaultDetection]))
-> (Maybe [DefaultDetection] -> f (Maybe [DefaultDetection]))
-> SensitiveDataItem
-> f SensitiveDataItem
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  [DefaultDetection]
  [DefaultDetection]
  [DefaultDetection]
  [DefaultDetection]
-> Iso
     (Maybe [DefaultDetection])
     (Maybe [DefaultDetection])
     (Maybe [DefaultDetection])
     (Maybe [DefaultDetection])
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
  [DefaultDetection]
  [DefaultDetection]
  [DefaultDetection]
  [DefaultDetection]
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:
-- CREDENTIALS, for credentials data such as private keys or Amazon Web
-- Services secret keys; FINANCIAL_INFORMATION, for financial data such as
-- credit card numbers; or, PERSONAL_INFORMATION, for personal health
-- information, such as health insurance identification numbers, or
-- personally identifiable information, such as passport numbers.
sensitiveDataItem_category :: Lens.Lens' SensitiveDataItem (Prelude.Maybe SensitiveDataItemCategory)
sensitiveDataItem_category :: (Maybe SensitiveDataItemCategory
 -> f (Maybe SensitiveDataItemCategory))
-> SensitiveDataItem -> f SensitiveDataItem
sensitiveDataItem_category = (SensitiveDataItem -> Maybe SensitiveDataItemCategory)
-> (SensitiveDataItem
    -> Maybe SensitiveDataItemCategory -> SensitiveDataItem)
-> Lens
     SensitiveDataItem
     SensitiveDataItem
     (Maybe SensitiveDataItemCategory)
     (Maybe SensitiveDataItemCategory)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SensitiveDataItem' {Maybe SensitiveDataItemCategory
category :: Maybe SensitiveDataItemCategory
$sel:category:SensitiveDataItem' :: SensitiveDataItem -> Maybe SensitiveDataItemCategory
category} -> Maybe SensitiveDataItemCategory
category) (\s :: SensitiveDataItem
s@SensitiveDataItem' {} Maybe SensitiveDataItemCategory
a -> SensitiveDataItem
s {$sel:category:SensitiveDataItem' :: Maybe SensitiveDataItemCategory
category = Maybe SensitiveDataItemCategory
a} :: SensitiveDataItem)

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

instance Core.FromJSON SensitiveDataItem where
  parseJSON :: Value -> Parser SensitiveDataItem
parseJSON =
    String
-> (Object -> Parser SensitiveDataItem)
-> Value
-> Parser SensitiveDataItem
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"SensitiveDataItem"
      ( \Object
x ->
          Maybe [DefaultDetection]
-> Maybe SensitiveDataItemCategory
-> Maybe Integer
-> SensitiveDataItem
SensitiveDataItem'
            (Maybe [DefaultDetection]
 -> Maybe SensitiveDataItemCategory
 -> Maybe Integer
 -> SensitiveDataItem)
-> Parser (Maybe [DefaultDetection])
-> Parser
     (Maybe SensitiveDataItemCategory
      -> Maybe Integer -> SensitiveDataItem)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe (Maybe [DefaultDetection]))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"detections" Parser (Maybe (Maybe [DefaultDetection]))
-> Maybe [DefaultDetection] -> Parser (Maybe [DefaultDetection])
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe [DefaultDetection]
forall a. Monoid a => a
Prelude.mempty)
            Parser
  (Maybe SensitiveDataItemCategory
   -> Maybe Integer -> SensitiveDataItem)
-> Parser (Maybe SensitiveDataItemCategory)
-> Parser (Maybe Integer -> SensitiveDataItem)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe SensitiveDataItemCategory)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"category")
            Parser (Maybe Integer -> SensitiveDataItem)
-> Parser (Maybe Integer) -> Parser SensitiveDataItem
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 SensitiveDataItem

instance Prelude.NFData SensitiveDataItem