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

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

-- | Provides information about a custom data identifier that produced a
-- sensitive data finding, and the sensitive data that it detected for the
-- finding.
--
-- /See:/ 'newCustomDetection' smart constructor.
data CustomDetection = CustomDetection'
  { -- | The location of 1-15 occurrences of the sensitive data that the custom
    -- data identifier detected. A finding includes location data for a maximum
    -- of 15 occurrences of sensitive data.
    CustomDetection -> Maybe Occurrences
occurrences :: Prelude.Maybe Occurrences,
    -- | The Amazon Resource Name (ARN) of the custom data identifier.
    CustomDetection -> Maybe Text
arn :: Prelude.Maybe Prelude.Text,
    -- | The total number of occurrences of the sensitive data that the custom
    -- data identifier detected.
    CustomDetection -> Maybe Integer
count :: Prelude.Maybe Prelude.Integer,
    -- | The name of the custom data identifier.
    CustomDetection -> Maybe Text
name :: Prelude.Maybe Prelude.Text
  }
  deriving (CustomDetection -> CustomDetection -> Bool
(CustomDetection -> CustomDetection -> Bool)
-> (CustomDetection -> CustomDetection -> Bool)
-> Eq CustomDetection
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CustomDetection -> CustomDetection -> Bool
$c/= :: CustomDetection -> CustomDetection -> Bool
== :: CustomDetection -> CustomDetection -> Bool
$c== :: CustomDetection -> CustomDetection -> Bool
Prelude.Eq, ReadPrec [CustomDetection]
ReadPrec CustomDetection
Int -> ReadS CustomDetection
ReadS [CustomDetection]
(Int -> ReadS CustomDetection)
-> ReadS [CustomDetection]
-> ReadPrec CustomDetection
-> ReadPrec [CustomDetection]
-> Read CustomDetection
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CustomDetection]
$creadListPrec :: ReadPrec [CustomDetection]
readPrec :: ReadPrec CustomDetection
$creadPrec :: ReadPrec CustomDetection
readList :: ReadS [CustomDetection]
$creadList :: ReadS [CustomDetection]
readsPrec :: Int -> ReadS CustomDetection
$creadsPrec :: Int -> ReadS CustomDetection
Prelude.Read, Int -> CustomDetection -> ShowS
[CustomDetection] -> ShowS
CustomDetection -> String
(Int -> CustomDetection -> ShowS)
-> (CustomDetection -> String)
-> ([CustomDetection] -> ShowS)
-> Show CustomDetection
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CustomDetection] -> ShowS
$cshowList :: [CustomDetection] -> ShowS
show :: CustomDetection -> String
$cshow :: CustomDetection -> String
showsPrec :: Int -> CustomDetection -> ShowS
$cshowsPrec :: Int -> CustomDetection -> ShowS
Prelude.Show, (forall x. CustomDetection -> Rep CustomDetection x)
-> (forall x. Rep CustomDetection x -> CustomDetection)
-> Generic CustomDetection
forall x. Rep CustomDetection x -> CustomDetection
forall x. CustomDetection -> Rep CustomDetection x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CustomDetection x -> CustomDetection
$cfrom :: forall x. CustomDetection -> Rep CustomDetection x
Prelude.Generic)

-- |
-- Create a value of 'CustomDetection' 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', 'customDetection_occurrences' - The location of 1-15 occurrences of the sensitive data that the custom
-- data identifier detected. A finding includes location data for a maximum
-- of 15 occurrences of sensitive data.
--
-- 'arn', 'customDetection_arn' - The Amazon Resource Name (ARN) of the custom data identifier.
--
-- 'count', 'customDetection_count' - The total number of occurrences of the sensitive data that the custom
-- data identifier detected.
--
-- 'name', 'customDetection_name' - The name of the custom data identifier.
newCustomDetection ::
  CustomDetection
newCustomDetection :: CustomDetection
newCustomDetection =
  CustomDetection' :: Maybe Occurrences
-> Maybe Text -> Maybe Integer -> Maybe Text -> CustomDetection
CustomDetection'
    { $sel:occurrences:CustomDetection' :: Maybe Occurrences
occurrences = Maybe Occurrences
forall a. Maybe a
Prelude.Nothing,
      $sel:arn:CustomDetection' :: Maybe Text
arn = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:count:CustomDetection' :: Maybe Integer
count = Maybe Integer
forall a. Maybe a
Prelude.Nothing,
      $sel:name:CustomDetection' :: Maybe Text
name = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | The location of 1-15 occurrences of the sensitive data that the custom
-- data identifier detected. A finding includes location data for a maximum
-- of 15 occurrences of sensitive data.
customDetection_occurrences :: Lens.Lens' CustomDetection (Prelude.Maybe Occurrences)
customDetection_occurrences :: (Maybe Occurrences -> f (Maybe Occurrences))
-> CustomDetection -> f CustomDetection
customDetection_occurrences = (CustomDetection -> Maybe Occurrences)
-> (CustomDetection -> Maybe Occurrences -> CustomDetection)
-> Lens
     CustomDetection
     CustomDetection
     (Maybe Occurrences)
     (Maybe Occurrences)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CustomDetection' {Maybe Occurrences
occurrences :: Maybe Occurrences
$sel:occurrences:CustomDetection' :: CustomDetection -> Maybe Occurrences
occurrences} -> Maybe Occurrences
occurrences) (\s :: CustomDetection
s@CustomDetection' {} Maybe Occurrences
a -> CustomDetection
s {$sel:occurrences:CustomDetection' :: Maybe Occurrences
occurrences = Maybe Occurrences
a} :: CustomDetection)

-- | The Amazon Resource Name (ARN) of the custom data identifier.
customDetection_arn :: Lens.Lens' CustomDetection (Prelude.Maybe Prelude.Text)
customDetection_arn :: (Maybe Text -> f (Maybe Text))
-> CustomDetection -> f CustomDetection
customDetection_arn = (CustomDetection -> Maybe Text)
-> (CustomDetection -> Maybe Text -> CustomDetection)
-> Lens CustomDetection CustomDetection (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CustomDetection' {Maybe Text
arn :: Maybe Text
$sel:arn:CustomDetection' :: CustomDetection -> Maybe Text
arn} -> Maybe Text
arn) (\s :: CustomDetection
s@CustomDetection' {} Maybe Text
a -> CustomDetection
s {$sel:arn:CustomDetection' :: Maybe Text
arn = Maybe Text
a} :: CustomDetection)

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

-- | The name of the custom data identifier.
customDetection_name :: Lens.Lens' CustomDetection (Prelude.Maybe Prelude.Text)
customDetection_name :: (Maybe Text -> f (Maybe Text))
-> CustomDetection -> f CustomDetection
customDetection_name = (CustomDetection -> Maybe Text)
-> (CustomDetection -> Maybe Text -> CustomDetection)
-> Lens CustomDetection CustomDetection (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CustomDetection' {Maybe Text
name :: Maybe Text
$sel:name:CustomDetection' :: CustomDetection -> Maybe Text
name} -> Maybe Text
name) (\s :: CustomDetection
s@CustomDetection' {} Maybe Text
a -> CustomDetection
s {$sel:name:CustomDetection' :: Maybe Text
name = Maybe Text
a} :: CustomDetection)

instance Core.FromJSON CustomDetection where
  parseJSON :: Value -> Parser CustomDetection
parseJSON =
    String
-> (Object -> Parser CustomDetection)
-> Value
-> Parser CustomDetection
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"CustomDetection"
      ( \Object
x ->
          Maybe Occurrences
-> Maybe Text -> Maybe Integer -> Maybe Text -> CustomDetection
CustomDetection'
            (Maybe Occurrences
 -> Maybe Text -> Maybe Integer -> Maybe Text -> CustomDetection)
-> Parser (Maybe Occurrences)
-> Parser
     (Maybe Text -> Maybe Integer -> Maybe Text -> CustomDetection)
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 Text -> Maybe Integer -> Maybe Text -> CustomDetection)
-> Parser (Maybe Text)
-> Parser (Maybe Integer -> Maybe Text -> CustomDetection)
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
"arn")
            Parser (Maybe Integer -> Maybe Text -> CustomDetection)
-> Parser (Maybe Integer) -> Parser (Maybe Text -> CustomDetection)
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 -> CustomDetection)
-> Parser (Maybe Text) -> Parser CustomDetection
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
"name")
      )

instance Prelude.Hashable CustomDetection

instance Prelude.NFData CustomDetection