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

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

-- | Contains an instance of sensitive data that was detected by a
-- customer-defined identifier.
--
-- /See:/ 'newCustomDataIdentifiersResult' smart constructor.
data CustomDataIdentifiersResult = CustomDataIdentifiersResult'
  { -- | The list of detected instances of sensitive data.
    CustomDataIdentifiersResult
-> Maybe [CustomDataIdentifiersDetections]
detections :: Prelude.Maybe [CustomDataIdentifiersDetections],
    -- | The total number of occurrences of sensitive data.
    CustomDataIdentifiersResult -> Maybe Integer
totalCount :: Prelude.Maybe Prelude.Integer
  }
  deriving (CustomDataIdentifiersResult -> CustomDataIdentifiersResult -> Bool
(CustomDataIdentifiersResult
 -> CustomDataIdentifiersResult -> Bool)
-> (CustomDataIdentifiersResult
    -> CustomDataIdentifiersResult -> Bool)
-> Eq CustomDataIdentifiersResult
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CustomDataIdentifiersResult -> CustomDataIdentifiersResult -> Bool
$c/= :: CustomDataIdentifiersResult -> CustomDataIdentifiersResult -> Bool
== :: CustomDataIdentifiersResult -> CustomDataIdentifiersResult -> Bool
$c== :: CustomDataIdentifiersResult -> CustomDataIdentifiersResult -> Bool
Prelude.Eq, ReadPrec [CustomDataIdentifiersResult]
ReadPrec CustomDataIdentifiersResult
Int -> ReadS CustomDataIdentifiersResult
ReadS [CustomDataIdentifiersResult]
(Int -> ReadS CustomDataIdentifiersResult)
-> ReadS [CustomDataIdentifiersResult]
-> ReadPrec CustomDataIdentifiersResult
-> ReadPrec [CustomDataIdentifiersResult]
-> Read CustomDataIdentifiersResult
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CustomDataIdentifiersResult]
$creadListPrec :: ReadPrec [CustomDataIdentifiersResult]
readPrec :: ReadPrec CustomDataIdentifiersResult
$creadPrec :: ReadPrec CustomDataIdentifiersResult
readList :: ReadS [CustomDataIdentifiersResult]
$creadList :: ReadS [CustomDataIdentifiersResult]
readsPrec :: Int -> ReadS CustomDataIdentifiersResult
$creadsPrec :: Int -> ReadS CustomDataIdentifiersResult
Prelude.Read, Int -> CustomDataIdentifiersResult -> ShowS
[CustomDataIdentifiersResult] -> ShowS
CustomDataIdentifiersResult -> String
(Int -> CustomDataIdentifiersResult -> ShowS)
-> (CustomDataIdentifiersResult -> String)
-> ([CustomDataIdentifiersResult] -> ShowS)
-> Show CustomDataIdentifiersResult
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CustomDataIdentifiersResult] -> ShowS
$cshowList :: [CustomDataIdentifiersResult] -> ShowS
show :: CustomDataIdentifiersResult -> String
$cshow :: CustomDataIdentifiersResult -> String
showsPrec :: Int -> CustomDataIdentifiersResult -> ShowS
$cshowsPrec :: Int -> CustomDataIdentifiersResult -> ShowS
Prelude.Show, (forall x.
 CustomDataIdentifiersResult -> Rep CustomDataIdentifiersResult x)
-> (forall x.
    Rep CustomDataIdentifiersResult x -> CustomDataIdentifiersResult)
-> Generic CustomDataIdentifiersResult
forall x.
Rep CustomDataIdentifiersResult x -> CustomDataIdentifiersResult
forall x.
CustomDataIdentifiersResult -> Rep CustomDataIdentifiersResult x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep CustomDataIdentifiersResult x -> CustomDataIdentifiersResult
$cfrom :: forall x.
CustomDataIdentifiersResult -> Rep CustomDataIdentifiersResult x
Prelude.Generic)

-- |
-- Create a value of 'CustomDataIdentifiersResult' 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', 'customDataIdentifiersResult_detections' - The list of detected instances of sensitive data.
--
-- 'totalCount', 'customDataIdentifiersResult_totalCount' - The total number of occurrences of sensitive data.
newCustomDataIdentifiersResult ::
  CustomDataIdentifiersResult
newCustomDataIdentifiersResult :: CustomDataIdentifiersResult
newCustomDataIdentifiersResult =
  CustomDataIdentifiersResult' :: Maybe [CustomDataIdentifiersDetections]
-> Maybe Integer -> CustomDataIdentifiersResult
CustomDataIdentifiersResult'
    { $sel:detections:CustomDataIdentifiersResult' :: Maybe [CustomDataIdentifiersDetections]
detections =
        Maybe [CustomDataIdentifiersDetections]
forall a. Maybe a
Prelude.Nothing,
      $sel:totalCount:CustomDataIdentifiersResult' :: Maybe Integer
totalCount = Maybe Integer
forall a. Maybe a
Prelude.Nothing
    }

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

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

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

instance Prelude.NFData CustomDataIdentifiersResult

instance Core.ToJSON CustomDataIdentifiersResult where
  toJSON :: CustomDataIdentifiersResult -> Value
toJSON CustomDataIdentifiersResult' {Maybe Integer
Maybe [CustomDataIdentifiersDetections]
totalCount :: Maybe Integer
detections :: Maybe [CustomDataIdentifiersDetections]
$sel:totalCount:CustomDataIdentifiersResult' :: CustomDataIdentifiersResult -> Maybe Integer
$sel:detections:CustomDataIdentifiersResult' :: CustomDataIdentifiersResult
-> Maybe [CustomDataIdentifiersDetections]
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"Detections" Text -> [CustomDataIdentifiersDetections] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) ([CustomDataIdentifiersDetections] -> Pair)
-> Maybe [CustomDataIdentifiersDetections] -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [CustomDataIdentifiersDetections]
detections,
            (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
          ]
      )