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

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import Amazonka.MacieV2.Types.CustomDetection
import qualified Amazonka.Prelude as Prelude

-- | Provides information about custom data identifiers that produced a
-- sensitive data finding, and the number of occurrences of the data that
-- they detected for the finding.
--
-- /See:/ 'newCustomDataIdentifiers' smart constructor.
data CustomDataIdentifiers = CustomDataIdentifiers'
  { -- | The custom data identifiers that detected the data, and the number of
    -- occurrences of the data that each identifier detected.
    CustomDataIdentifiers -> Maybe [CustomDetection]
detections :: Prelude.Maybe [CustomDetection],
    -- | The total number of occurrences of the data that was detected by the
    -- custom data identifiers and produced the finding.
    CustomDataIdentifiers -> Maybe Integer
totalCount :: Prelude.Maybe Prelude.Integer
  }
  deriving (CustomDataIdentifiers -> CustomDataIdentifiers -> Bool
(CustomDataIdentifiers -> CustomDataIdentifiers -> Bool)
-> (CustomDataIdentifiers -> CustomDataIdentifiers -> Bool)
-> Eq CustomDataIdentifiers
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CustomDataIdentifiers -> CustomDataIdentifiers -> Bool
$c/= :: CustomDataIdentifiers -> CustomDataIdentifiers -> Bool
== :: CustomDataIdentifiers -> CustomDataIdentifiers -> Bool
$c== :: CustomDataIdentifiers -> CustomDataIdentifiers -> Bool
Prelude.Eq, ReadPrec [CustomDataIdentifiers]
ReadPrec CustomDataIdentifiers
Int -> ReadS CustomDataIdentifiers
ReadS [CustomDataIdentifiers]
(Int -> ReadS CustomDataIdentifiers)
-> ReadS [CustomDataIdentifiers]
-> ReadPrec CustomDataIdentifiers
-> ReadPrec [CustomDataIdentifiers]
-> Read CustomDataIdentifiers
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CustomDataIdentifiers]
$creadListPrec :: ReadPrec [CustomDataIdentifiers]
readPrec :: ReadPrec CustomDataIdentifiers
$creadPrec :: ReadPrec CustomDataIdentifiers
readList :: ReadS [CustomDataIdentifiers]
$creadList :: ReadS [CustomDataIdentifiers]
readsPrec :: Int -> ReadS CustomDataIdentifiers
$creadsPrec :: Int -> ReadS CustomDataIdentifiers
Prelude.Read, Int -> CustomDataIdentifiers -> ShowS
[CustomDataIdentifiers] -> ShowS
CustomDataIdentifiers -> String
(Int -> CustomDataIdentifiers -> ShowS)
-> (CustomDataIdentifiers -> String)
-> ([CustomDataIdentifiers] -> ShowS)
-> Show CustomDataIdentifiers
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CustomDataIdentifiers] -> ShowS
$cshowList :: [CustomDataIdentifiers] -> ShowS
show :: CustomDataIdentifiers -> String
$cshow :: CustomDataIdentifiers -> String
showsPrec :: Int -> CustomDataIdentifiers -> ShowS
$cshowsPrec :: Int -> CustomDataIdentifiers -> ShowS
Prelude.Show, (forall x. CustomDataIdentifiers -> Rep CustomDataIdentifiers x)
-> (forall x. Rep CustomDataIdentifiers x -> CustomDataIdentifiers)
-> Generic CustomDataIdentifiers
forall x. Rep CustomDataIdentifiers x -> CustomDataIdentifiers
forall x. CustomDataIdentifiers -> Rep CustomDataIdentifiers x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CustomDataIdentifiers x -> CustomDataIdentifiers
$cfrom :: forall x. CustomDataIdentifiers -> Rep CustomDataIdentifiers x
Prelude.Generic)

-- |
-- Create a value of 'CustomDataIdentifiers' 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', 'customDataIdentifiers_detections' - The custom data identifiers that detected the data, and the number of
-- occurrences of the data that each identifier detected.
--
-- 'totalCount', 'customDataIdentifiers_totalCount' - The total number of occurrences of the data that was detected by the
-- custom data identifiers and produced the finding.
newCustomDataIdentifiers ::
  CustomDataIdentifiers
newCustomDataIdentifiers :: CustomDataIdentifiers
newCustomDataIdentifiers =
  CustomDataIdentifiers' :: Maybe [CustomDetection] -> Maybe Integer -> CustomDataIdentifiers
CustomDataIdentifiers'
    { $sel:detections:CustomDataIdentifiers' :: Maybe [CustomDetection]
detections =
        Maybe [CustomDetection]
forall a. Maybe a
Prelude.Nothing,
      $sel:totalCount:CustomDataIdentifiers' :: Maybe Integer
totalCount = Maybe Integer
forall a. Maybe a
Prelude.Nothing
    }

-- | The custom data identifiers that detected the data, and the number of
-- occurrences of the data that each identifier detected.
customDataIdentifiers_detections :: Lens.Lens' CustomDataIdentifiers (Prelude.Maybe [CustomDetection])
customDataIdentifiers_detections :: (Maybe [CustomDetection] -> f (Maybe [CustomDetection]))
-> CustomDataIdentifiers -> f CustomDataIdentifiers
customDataIdentifiers_detections = (CustomDataIdentifiers -> Maybe [CustomDetection])
-> (CustomDataIdentifiers
    -> Maybe [CustomDetection] -> CustomDataIdentifiers)
-> Lens
     CustomDataIdentifiers
     CustomDataIdentifiers
     (Maybe [CustomDetection])
     (Maybe [CustomDetection])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CustomDataIdentifiers' {Maybe [CustomDetection]
detections :: Maybe [CustomDetection]
$sel:detections:CustomDataIdentifiers' :: CustomDataIdentifiers -> Maybe [CustomDetection]
detections} -> Maybe [CustomDetection]
detections) (\s :: CustomDataIdentifiers
s@CustomDataIdentifiers' {} Maybe [CustomDetection]
a -> CustomDataIdentifiers
s {$sel:detections:CustomDataIdentifiers' :: Maybe [CustomDetection]
detections = Maybe [CustomDetection]
a} :: CustomDataIdentifiers) ((Maybe [CustomDetection] -> f (Maybe [CustomDetection]))
 -> CustomDataIdentifiers -> f CustomDataIdentifiers)
-> ((Maybe [CustomDetection] -> f (Maybe [CustomDetection]))
    -> Maybe [CustomDetection] -> f (Maybe [CustomDetection]))
-> (Maybe [CustomDetection] -> f (Maybe [CustomDetection]))
-> CustomDataIdentifiers
-> f CustomDataIdentifiers
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  [CustomDetection]
  [CustomDetection]
  [CustomDetection]
  [CustomDetection]
-> Iso
     (Maybe [CustomDetection])
     (Maybe [CustomDetection])
     (Maybe [CustomDetection])
     (Maybe [CustomDetection])
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
  [CustomDetection]
  [CustomDetection]
  [CustomDetection]
  [CustomDetection]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The total number of occurrences of the data that was detected by the
-- custom data identifiers and produced the finding.
customDataIdentifiers_totalCount :: Lens.Lens' CustomDataIdentifiers (Prelude.Maybe Prelude.Integer)
customDataIdentifiers_totalCount :: (Maybe Integer -> f (Maybe Integer))
-> CustomDataIdentifiers -> f CustomDataIdentifiers
customDataIdentifiers_totalCount = (CustomDataIdentifiers -> Maybe Integer)
-> (CustomDataIdentifiers
    -> Maybe Integer -> CustomDataIdentifiers)
-> Lens
     CustomDataIdentifiers
     CustomDataIdentifiers
     (Maybe Integer)
     (Maybe Integer)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CustomDataIdentifiers' {Maybe Integer
totalCount :: Maybe Integer
$sel:totalCount:CustomDataIdentifiers' :: CustomDataIdentifiers -> Maybe Integer
totalCount} -> Maybe Integer
totalCount) (\s :: CustomDataIdentifiers
s@CustomDataIdentifiers' {} Maybe Integer
a -> CustomDataIdentifiers
s {$sel:totalCount:CustomDataIdentifiers' :: Maybe Integer
totalCount = Maybe Integer
a} :: CustomDataIdentifiers)

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

instance Prelude.NFData CustomDataIdentifiers