{-# 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.DataBrew.Types.EntityDetectorConfiguration
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.DataBrew.Types.EntityDetectorConfiguration where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.DataBrew.Types.AllowedStatistics
import qualified Amazonka.Prelude as Prelude

-- | Configuration of entity detection for a profile job. When undefined,
-- entity detection is disabled.
--
-- /See:/ 'newEntityDetectorConfiguration' smart constructor.
data EntityDetectorConfiguration = EntityDetectorConfiguration'
  { -- | Configuration of statistics that are allowed to be run on columns that
    -- contain detected entities. When undefined, no statistics will be
    -- computed on columns that contain detected entities.
    EntityDetectorConfiguration -> Maybe (NonEmpty AllowedStatistics)
allowedStatistics :: Prelude.Maybe (Prelude.NonEmpty AllowedStatistics),
    -- | Entity types to detect. Can be any of the following:
    --
    -- -   USA_SSN
    --
    -- -   EMAIL
    --
    -- -   USA_ITIN
    --
    -- -   USA_PASSPORT_NUMBER
    --
    -- -   PHONE_NUMBER
    --
    -- -   USA_DRIVING_LICENSE
    --
    -- -   BANK_ACCOUNT
    --
    -- -   CREDIT_CARD
    --
    -- -   IP_ADDRESS
    --
    -- -   MAC_ADDRESS
    --
    -- -   USA_DEA_NUMBER
    --
    -- -   USA_HCPCS_CODE
    --
    -- -   USA_NATIONAL_PROVIDER_IDENTIFIER
    --
    -- -   USA_NATIONAL_DRUG_CODE
    --
    -- -   USA_HEALTH_INSURANCE_CLAIM_NUMBER
    --
    -- -   USA_MEDICARE_BENEFICIARY_IDENTIFIER
    --
    -- -   USA_CPT_CODE
    --
    -- -   PERSON_NAME
    --
    -- -   DATE
    --
    -- The Entity type group USA_ALL is also supported, and includes all of the
    -- above entity types except PERSON_NAME and DATE.
    EntityDetectorConfiguration -> NonEmpty Text
entityTypes :: Prelude.NonEmpty Prelude.Text
  }
  deriving (EntityDetectorConfiguration -> EntityDetectorConfiguration -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: EntityDetectorConfiguration -> EntityDetectorConfiguration -> Bool
$c/= :: EntityDetectorConfiguration -> EntityDetectorConfiguration -> Bool
== :: EntityDetectorConfiguration -> EntityDetectorConfiguration -> Bool
$c== :: EntityDetectorConfiguration -> EntityDetectorConfiguration -> Bool
Prelude.Eq, ReadPrec [EntityDetectorConfiguration]
ReadPrec EntityDetectorConfiguration
Int -> ReadS EntityDetectorConfiguration
ReadS [EntityDetectorConfiguration]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [EntityDetectorConfiguration]
$creadListPrec :: ReadPrec [EntityDetectorConfiguration]
readPrec :: ReadPrec EntityDetectorConfiguration
$creadPrec :: ReadPrec EntityDetectorConfiguration
readList :: ReadS [EntityDetectorConfiguration]
$creadList :: ReadS [EntityDetectorConfiguration]
readsPrec :: Int -> ReadS EntityDetectorConfiguration
$creadsPrec :: Int -> ReadS EntityDetectorConfiguration
Prelude.Read, Int -> EntityDetectorConfiguration -> ShowS
[EntityDetectorConfiguration] -> ShowS
EntityDetectorConfiguration -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [EntityDetectorConfiguration] -> ShowS
$cshowList :: [EntityDetectorConfiguration] -> ShowS
show :: EntityDetectorConfiguration -> String
$cshow :: EntityDetectorConfiguration -> String
showsPrec :: Int -> EntityDetectorConfiguration -> ShowS
$cshowsPrec :: Int -> EntityDetectorConfiguration -> ShowS
Prelude.Show, forall x.
Rep EntityDetectorConfiguration x -> EntityDetectorConfiguration
forall x.
EntityDetectorConfiguration -> Rep EntityDetectorConfiguration x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep EntityDetectorConfiguration x -> EntityDetectorConfiguration
$cfrom :: forall x.
EntityDetectorConfiguration -> Rep EntityDetectorConfiguration x
Prelude.Generic)

-- |
-- Create a value of 'EntityDetectorConfiguration' 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:
--
-- 'allowedStatistics', 'entityDetectorConfiguration_allowedStatistics' - Configuration of statistics that are allowed to be run on columns that
-- contain detected entities. When undefined, no statistics will be
-- computed on columns that contain detected entities.
--
-- 'entityTypes', 'entityDetectorConfiguration_entityTypes' - Entity types to detect. Can be any of the following:
--
-- -   USA_SSN
--
-- -   EMAIL
--
-- -   USA_ITIN
--
-- -   USA_PASSPORT_NUMBER
--
-- -   PHONE_NUMBER
--
-- -   USA_DRIVING_LICENSE
--
-- -   BANK_ACCOUNT
--
-- -   CREDIT_CARD
--
-- -   IP_ADDRESS
--
-- -   MAC_ADDRESS
--
-- -   USA_DEA_NUMBER
--
-- -   USA_HCPCS_CODE
--
-- -   USA_NATIONAL_PROVIDER_IDENTIFIER
--
-- -   USA_NATIONAL_DRUG_CODE
--
-- -   USA_HEALTH_INSURANCE_CLAIM_NUMBER
--
-- -   USA_MEDICARE_BENEFICIARY_IDENTIFIER
--
-- -   USA_CPT_CODE
--
-- -   PERSON_NAME
--
-- -   DATE
--
-- The Entity type group USA_ALL is also supported, and includes all of the
-- above entity types except PERSON_NAME and DATE.
newEntityDetectorConfiguration ::
  -- | 'entityTypes'
  Prelude.NonEmpty Prelude.Text ->
  EntityDetectorConfiguration
newEntityDetectorConfiguration :: NonEmpty Text -> EntityDetectorConfiguration
newEntityDetectorConfiguration NonEmpty Text
pEntityTypes_ =
  EntityDetectorConfiguration'
    { $sel:allowedStatistics:EntityDetectorConfiguration' :: Maybe (NonEmpty AllowedStatistics)
allowedStatistics =
        forall a. Maybe a
Prelude.Nothing,
      $sel:entityTypes:EntityDetectorConfiguration' :: NonEmpty Text
entityTypes =
        forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced forall t b. AReview t b -> b -> t
Lens.# NonEmpty Text
pEntityTypes_
    }

-- | Configuration of statistics that are allowed to be run on columns that
-- contain detected entities. When undefined, no statistics will be
-- computed on columns that contain detected entities.
entityDetectorConfiguration_allowedStatistics :: Lens.Lens' EntityDetectorConfiguration (Prelude.Maybe (Prelude.NonEmpty AllowedStatistics))
entityDetectorConfiguration_allowedStatistics :: Lens'
  EntityDetectorConfiguration (Maybe (NonEmpty AllowedStatistics))
entityDetectorConfiguration_allowedStatistics = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\EntityDetectorConfiguration' {Maybe (NonEmpty AllowedStatistics)
allowedStatistics :: Maybe (NonEmpty AllowedStatistics)
$sel:allowedStatistics:EntityDetectorConfiguration' :: EntityDetectorConfiguration -> Maybe (NonEmpty AllowedStatistics)
allowedStatistics} -> Maybe (NonEmpty AllowedStatistics)
allowedStatistics) (\s :: EntityDetectorConfiguration
s@EntityDetectorConfiguration' {} Maybe (NonEmpty AllowedStatistics)
a -> EntityDetectorConfiguration
s {$sel:allowedStatistics:EntityDetectorConfiguration' :: Maybe (NonEmpty AllowedStatistics)
allowedStatistics = Maybe (NonEmpty AllowedStatistics)
a} :: EntityDetectorConfiguration) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. 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 forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | Entity types to detect. Can be any of the following:
--
-- -   USA_SSN
--
-- -   EMAIL
--
-- -   USA_ITIN
--
-- -   USA_PASSPORT_NUMBER
--
-- -   PHONE_NUMBER
--
-- -   USA_DRIVING_LICENSE
--
-- -   BANK_ACCOUNT
--
-- -   CREDIT_CARD
--
-- -   IP_ADDRESS
--
-- -   MAC_ADDRESS
--
-- -   USA_DEA_NUMBER
--
-- -   USA_HCPCS_CODE
--
-- -   USA_NATIONAL_PROVIDER_IDENTIFIER
--
-- -   USA_NATIONAL_DRUG_CODE
--
-- -   USA_HEALTH_INSURANCE_CLAIM_NUMBER
--
-- -   USA_MEDICARE_BENEFICIARY_IDENTIFIER
--
-- -   USA_CPT_CODE
--
-- -   PERSON_NAME
--
-- -   DATE
--
-- The Entity type group USA_ALL is also supported, and includes all of the
-- above entity types except PERSON_NAME and DATE.
entityDetectorConfiguration_entityTypes :: Lens.Lens' EntityDetectorConfiguration (Prelude.NonEmpty Prelude.Text)
entityDetectorConfiguration_entityTypes :: Lens' EntityDetectorConfiguration (NonEmpty Text)
entityDetectorConfiguration_entityTypes = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\EntityDetectorConfiguration' {NonEmpty Text
entityTypes :: NonEmpty Text
$sel:entityTypes:EntityDetectorConfiguration' :: EntityDetectorConfiguration -> NonEmpty Text
entityTypes} -> NonEmpty Text
entityTypes) (\s :: EntityDetectorConfiguration
s@EntityDetectorConfiguration' {} NonEmpty Text
a -> EntityDetectorConfiguration
s {$sel:entityTypes:EntityDetectorConfiguration' :: NonEmpty Text
entityTypes = NonEmpty Text
a} :: EntityDetectorConfiguration) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Data.FromJSON EntityDetectorConfiguration where
  parseJSON :: Value -> Parser EntityDetectorConfiguration
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"EntityDetectorConfiguration"
      ( \Object
x ->
          Maybe (NonEmpty AllowedStatistics)
-> NonEmpty Text -> EntityDetectorConfiguration
EntityDetectorConfiguration'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"AllowedStatistics")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"EntityTypes")
      )

instance Prelude.Hashable EntityDetectorConfiguration where
  hashWithSalt :: Int -> EntityDetectorConfiguration -> Int
hashWithSalt Int
_salt EntityDetectorConfiguration' {Maybe (NonEmpty AllowedStatistics)
NonEmpty Text
entityTypes :: NonEmpty Text
allowedStatistics :: Maybe (NonEmpty AllowedStatistics)
$sel:entityTypes:EntityDetectorConfiguration' :: EntityDetectorConfiguration -> NonEmpty Text
$sel:allowedStatistics:EntityDetectorConfiguration' :: EntityDetectorConfiguration -> Maybe (NonEmpty AllowedStatistics)
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe (NonEmpty AllowedStatistics)
allowedStatistics
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` NonEmpty Text
entityTypes

instance Prelude.NFData EntityDetectorConfiguration where
  rnf :: EntityDetectorConfiguration -> ()
rnf EntityDetectorConfiguration' {Maybe (NonEmpty AllowedStatistics)
NonEmpty Text
entityTypes :: NonEmpty Text
allowedStatistics :: Maybe (NonEmpty AllowedStatistics)
$sel:entityTypes:EntityDetectorConfiguration' :: EntityDetectorConfiguration -> NonEmpty Text
$sel:allowedStatistics:EntityDetectorConfiguration' :: EntityDetectorConfiguration -> Maybe (NonEmpty AllowedStatistics)
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe (NonEmpty AllowedStatistics)
allowedStatistics
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf NonEmpty Text
entityTypes

instance Data.ToJSON EntityDetectorConfiguration where
  toJSON :: EntityDetectorConfiguration -> Value
toJSON EntityDetectorConfiguration' {Maybe (NonEmpty AllowedStatistics)
NonEmpty Text
entityTypes :: NonEmpty Text
allowedStatistics :: Maybe (NonEmpty AllowedStatistics)
$sel:entityTypes:EntityDetectorConfiguration' :: EntityDetectorConfiguration -> NonEmpty Text
$sel:allowedStatistics:EntityDetectorConfiguration' :: EntityDetectorConfiguration -> Maybe (NonEmpty AllowedStatistics)
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"AllowedStatistics" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=)
              forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe (NonEmpty AllowedStatistics)
allowedStatistics,
            forall a. a -> Maybe a
Prelude.Just (Key
"EntityTypes" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= NonEmpty Text
entityTypes)
          ]
      )