{-# 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.Glue.Types.CustomEntityType
-- 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.Glue.Types.CustomEntityType where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import qualified Amazonka.Prelude as Prelude

-- | An object representing a custom pattern for detecting sensitive data
-- across the columns and rows of your structured data.
--
-- /See:/ 'newCustomEntityType' smart constructor.
data CustomEntityType = CustomEntityType'
  { -- | A list of context words. If none of these context words are found within
    -- the vicinity of the regular expression the data will not be detected as
    -- sensitive data.
    --
    -- If no context words are passed only a regular expression is checked.
    CustomEntityType -> Maybe (NonEmpty Text)
contextWords :: Prelude.Maybe (Prelude.NonEmpty Prelude.Text),
    -- | A name for the custom pattern that allows it to be retrieved or deleted
    -- later. This name must be unique per Amazon Web Services account.
    CustomEntityType -> Text
name :: Prelude.Text,
    -- | A regular expression string that is used for detecting sensitive data in
    -- a custom pattern.
    CustomEntityType -> Text
regexString :: Prelude.Text
  }
  deriving (CustomEntityType -> CustomEntityType -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CustomEntityType -> CustomEntityType -> Bool
$c/= :: CustomEntityType -> CustomEntityType -> Bool
== :: CustomEntityType -> CustomEntityType -> Bool
$c== :: CustomEntityType -> CustomEntityType -> Bool
Prelude.Eq, ReadPrec [CustomEntityType]
ReadPrec CustomEntityType
Int -> ReadS CustomEntityType
ReadS [CustomEntityType]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CustomEntityType]
$creadListPrec :: ReadPrec [CustomEntityType]
readPrec :: ReadPrec CustomEntityType
$creadPrec :: ReadPrec CustomEntityType
readList :: ReadS [CustomEntityType]
$creadList :: ReadS [CustomEntityType]
readsPrec :: Int -> ReadS CustomEntityType
$creadsPrec :: Int -> ReadS CustomEntityType
Prelude.Read, Int -> CustomEntityType -> ShowS
[CustomEntityType] -> ShowS
CustomEntityType -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CustomEntityType] -> ShowS
$cshowList :: [CustomEntityType] -> ShowS
show :: CustomEntityType -> String
$cshow :: CustomEntityType -> String
showsPrec :: Int -> CustomEntityType -> ShowS
$cshowsPrec :: Int -> CustomEntityType -> ShowS
Prelude.Show, forall x. Rep CustomEntityType x -> CustomEntityType
forall x. CustomEntityType -> Rep CustomEntityType x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CustomEntityType x -> CustomEntityType
$cfrom :: forall x. CustomEntityType -> Rep CustomEntityType x
Prelude.Generic)

-- |
-- Create a value of 'CustomEntityType' 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:
--
-- 'contextWords', 'customEntityType_contextWords' - A list of context words. If none of these context words are found within
-- the vicinity of the regular expression the data will not be detected as
-- sensitive data.
--
-- If no context words are passed only a regular expression is checked.
--
-- 'name', 'customEntityType_name' - A name for the custom pattern that allows it to be retrieved or deleted
-- later. This name must be unique per Amazon Web Services account.
--
-- 'regexString', 'customEntityType_regexString' - A regular expression string that is used for detecting sensitive data in
-- a custom pattern.
newCustomEntityType ::
  -- | 'name'
  Prelude.Text ->
  -- | 'regexString'
  Prelude.Text ->
  CustomEntityType
newCustomEntityType :: Text -> Text -> CustomEntityType
newCustomEntityType Text
pName_ Text
pRegexString_ =
  CustomEntityType'
    { $sel:contextWords:CustomEntityType' :: Maybe (NonEmpty Text)
contextWords = forall a. Maybe a
Prelude.Nothing,
      $sel:name:CustomEntityType' :: Text
name = Text
pName_,
      $sel:regexString:CustomEntityType' :: Text
regexString = Text
pRegexString_
    }

-- | A list of context words. If none of these context words are found within
-- the vicinity of the regular expression the data will not be detected as
-- sensitive data.
--
-- If no context words are passed only a regular expression is checked.
customEntityType_contextWords :: Lens.Lens' CustomEntityType (Prelude.Maybe (Prelude.NonEmpty Prelude.Text))
customEntityType_contextWords :: Lens' CustomEntityType (Maybe (NonEmpty Text))
customEntityType_contextWords = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CustomEntityType' {Maybe (NonEmpty Text)
contextWords :: Maybe (NonEmpty Text)
$sel:contextWords:CustomEntityType' :: CustomEntityType -> Maybe (NonEmpty Text)
contextWords} -> Maybe (NonEmpty Text)
contextWords) (\s :: CustomEntityType
s@CustomEntityType' {} Maybe (NonEmpty Text)
a -> CustomEntityType
s {$sel:contextWords:CustomEntityType' :: Maybe (NonEmpty Text)
contextWords = Maybe (NonEmpty Text)
a} :: CustomEntityType) 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

-- | A name for the custom pattern that allows it to be retrieved or deleted
-- later. This name must be unique per Amazon Web Services account.
customEntityType_name :: Lens.Lens' CustomEntityType Prelude.Text
customEntityType_name :: Lens' CustomEntityType Text
customEntityType_name = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CustomEntityType' {Text
name :: Text
$sel:name:CustomEntityType' :: CustomEntityType -> Text
name} -> Text
name) (\s :: CustomEntityType
s@CustomEntityType' {} Text
a -> CustomEntityType
s {$sel:name:CustomEntityType' :: Text
name = Text
a} :: CustomEntityType)

-- | A regular expression string that is used for detecting sensitive data in
-- a custom pattern.
customEntityType_regexString :: Lens.Lens' CustomEntityType Prelude.Text
customEntityType_regexString :: Lens' CustomEntityType Text
customEntityType_regexString = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CustomEntityType' {Text
regexString :: Text
$sel:regexString:CustomEntityType' :: CustomEntityType -> Text
regexString} -> Text
regexString) (\s :: CustomEntityType
s@CustomEntityType' {} Text
a -> CustomEntityType
s {$sel:regexString:CustomEntityType' :: Text
regexString = Text
a} :: CustomEntityType)

instance Data.FromJSON CustomEntityType where
  parseJSON :: Value -> Parser CustomEntityType
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"CustomEntityType"
      ( \Object
x ->
          Maybe (NonEmpty Text) -> Text -> Text -> CustomEntityType
CustomEntityType'
            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
"ContextWords")
            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
"Name")
            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
"RegexString")
      )

instance Prelude.Hashable CustomEntityType where
  hashWithSalt :: Int -> CustomEntityType -> Int
hashWithSalt Int
_salt CustomEntityType' {Maybe (NonEmpty Text)
Text
regexString :: Text
name :: Text
contextWords :: Maybe (NonEmpty Text)
$sel:regexString:CustomEntityType' :: CustomEntityType -> Text
$sel:name:CustomEntityType' :: CustomEntityType -> Text
$sel:contextWords:CustomEntityType' :: CustomEntityType -> Maybe (NonEmpty Text)
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe (NonEmpty Text)
contextWords
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
name
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
regexString

instance Prelude.NFData CustomEntityType where
  rnf :: CustomEntityType -> ()
rnf CustomEntityType' {Maybe (NonEmpty Text)
Text
regexString :: Text
name :: Text
contextWords :: Maybe (NonEmpty Text)
$sel:regexString:CustomEntityType' :: CustomEntityType -> Text
$sel:name:CustomEntityType' :: CustomEntityType -> Text
$sel:contextWords:CustomEntityType' :: CustomEntityType -> Maybe (NonEmpty Text)
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe (NonEmpty Text)
contextWords
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
name
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
regexString