{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE StrictData #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# OPTIONS_GHC -fno-warn-unused-binds #-}
{-# 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.GetCustomEntityType
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Retrieves the details of a custom pattern by specifying its name.
module Amazonka.Glue.GetCustomEntityType
  ( -- * Creating a Request
    GetCustomEntityType (..),
    newGetCustomEntityType,

    -- * Request Lenses
    getCustomEntityType_name,

    -- * Destructuring the Response
    GetCustomEntityTypeResponse (..),
    newGetCustomEntityTypeResponse,

    -- * Response Lenses
    getCustomEntityTypeResponse_contextWords,
    getCustomEntityTypeResponse_name,
    getCustomEntityTypeResponse_regexString,
    getCustomEntityTypeResponse_httpStatus,
  )
where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.Glue.Types
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response

-- | /See:/ 'newGetCustomEntityType' smart constructor.
data GetCustomEntityType = GetCustomEntityType'
  { -- | The name of the custom pattern that you want to retrieve.
    GetCustomEntityType -> Text
name :: Prelude.Text
  }
  deriving (GetCustomEntityType -> GetCustomEntityType -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetCustomEntityType -> GetCustomEntityType -> Bool
$c/= :: GetCustomEntityType -> GetCustomEntityType -> Bool
== :: GetCustomEntityType -> GetCustomEntityType -> Bool
$c== :: GetCustomEntityType -> GetCustomEntityType -> Bool
Prelude.Eq, ReadPrec [GetCustomEntityType]
ReadPrec GetCustomEntityType
Int -> ReadS GetCustomEntityType
ReadS [GetCustomEntityType]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetCustomEntityType]
$creadListPrec :: ReadPrec [GetCustomEntityType]
readPrec :: ReadPrec GetCustomEntityType
$creadPrec :: ReadPrec GetCustomEntityType
readList :: ReadS [GetCustomEntityType]
$creadList :: ReadS [GetCustomEntityType]
readsPrec :: Int -> ReadS GetCustomEntityType
$creadsPrec :: Int -> ReadS GetCustomEntityType
Prelude.Read, Int -> GetCustomEntityType -> ShowS
[GetCustomEntityType] -> ShowS
GetCustomEntityType -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetCustomEntityType] -> ShowS
$cshowList :: [GetCustomEntityType] -> ShowS
show :: GetCustomEntityType -> String
$cshow :: GetCustomEntityType -> String
showsPrec :: Int -> GetCustomEntityType -> ShowS
$cshowsPrec :: Int -> GetCustomEntityType -> ShowS
Prelude.Show, forall x. Rep GetCustomEntityType x -> GetCustomEntityType
forall x. GetCustomEntityType -> Rep GetCustomEntityType x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GetCustomEntityType x -> GetCustomEntityType
$cfrom :: forall x. GetCustomEntityType -> Rep GetCustomEntityType x
Prelude.Generic)

-- |
-- Create a value of 'GetCustomEntityType' 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:
--
-- 'name', 'getCustomEntityType_name' - The name of the custom pattern that you want to retrieve.
newGetCustomEntityType ::
  -- | 'name'
  Prelude.Text ->
  GetCustomEntityType
newGetCustomEntityType :: Text -> GetCustomEntityType
newGetCustomEntityType Text
pName_ =
  GetCustomEntityType' {$sel:name:GetCustomEntityType' :: Text
name = Text
pName_}

-- | The name of the custom pattern that you want to retrieve.
getCustomEntityType_name :: Lens.Lens' GetCustomEntityType Prelude.Text
getCustomEntityType_name :: Lens' GetCustomEntityType Text
getCustomEntityType_name = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetCustomEntityType' {Text
name :: Text
$sel:name:GetCustomEntityType' :: GetCustomEntityType -> Text
name} -> Text
name) (\s :: GetCustomEntityType
s@GetCustomEntityType' {} Text
a -> GetCustomEntityType
s {$sel:name:GetCustomEntityType' :: Text
name = Text
a} :: GetCustomEntityType)

instance Core.AWSRequest GetCustomEntityType where
  type
    AWSResponse GetCustomEntityType =
      GetCustomEntityTypeResponse
  request :: (Service -> Service)
-> GetCustomEntityType -> Request GetCustomEntityType
request Service -> Service
overrides =
    forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON (Service -> Service
overrides Service
defaultService)
  response :: forall (m :: * -> *).
MonadResource m =>
(ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy GetCustomEntityType
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse GetCustomEntityType)))
response =
    forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> Object -> Either String (AWSResponse a))
-> (ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveJSON
      ( \Int
s ResponseHeaders
h Object
x ->
          Maybe (NonEmpty Text)
-> Maybe Text -> Maybe Text -> Int -> GetCustomEntityTypeResponse
GetCustomEntityTypeResponse'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Either String (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 -> Either String (Maybe 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 -> Either String (Maybe a)
Data..?> Key
"RegexString")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
      )

instance Prelude.Hashable GetCustomEntityType where
  hashWithSalt :: Int -> GetCustomEntityType -> Int
hashWithSalt Int
_salt GetCustomEntityType' {Text
name :: Text
$sel:name:GetCustomEntityType' :: GetCustomEntityType -> Text
..} =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
name

instance Prelude.NFData GetCustomEntityType where
  rnf :: GetCustomEntityType -> ()
rnf GetCustomEntityType' {Text
name :: Text
$sel:name:GetCustomEntityType' :: GetCustomEntityType -> Text
..} = forall a. NFData a => a -> ()
Prelude.rnf Text
name

instance Data.ToHeaders GetCustomEntityType where
  toHeaders :: GetCustomEntityType -> ResponseHeaders
toHeaders =
    forall a b. a -> b -> a
Prelude.const
      ( forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"X-Amz-Target"
              forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Data.=# ( ByteString
"AWSGlue.GetCustomEntityType" ::
                          Prelude.ByteString
                      ),
            HeaderName
"Content-Type"
              forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Data.=# ( ByteString
"application/x-amz-json-1.1" ::
                          Prelude.ByteString
                      )
          ]
      )

instance Data.ToJSON GetCustomEntityType where
  toJSON :: GetCustomEntityType -> Value
toJSON GetCustomEntityType' {Text
name :: Text
$sel:name:GetCustomEntityType' :: GetCustomEntityType -> Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [forall a. a -> Maybe a
Prelude.Just (Key
"Name" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
name)]
      )

instance Data.ToPath GetCustomEntityType where
  toPath :: GetCustomEntityType -> ByteString
toPath = forall a b. a -> b -> a
Prelude.const ByteString
"/"

instance Data.ToQuery GetCustomEntityType where
  toQuery :: GetCustomEntityType -> QueryString
toQuery = forall a b. a -> b -> a
Prelude.const forall a. Monoid a => a
Prelude.mempty

-- | /See:/ 'newGetCustomEntityTypeResponse' smart constructor.
data GetCustomEntityTypeResponse = GetCustomEntityTypeResponse'
  { -- | A list of context words if specified when you created the custom
    -- pattern. If none of these context words are found within the vicinity of
    -- the regular expression the data will not be detected as sensitive data.
    GetCustomEntityTypeResponse -> Maybe (NonEmpty Text)
contextWords :: Prelude.Maybe (Prelude.NonEmpty Prelude.Text),
    -- | The name of the custom pattern that you retrieved.
    GetCustomEntityTypeResponse -> Maybe Text
name :: Prelude.Maybe Prelude.Text,
    -- | A regular expression string that is used for detecting sensitive data in
    -- a custom pattern.
    GetCustomEntityTypeResponse -> Maybe Text
regexString :: Prelude.Maybe Prelude.Text,
    -- | The response's http status code.
    GetCustomEntityTypeResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (GetCustomEntityTypeResponse -> GetCustomEntityTypeResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetCustomEntityTypeResponse -> GetCustomEntityTypeResponse -> Bool
$c/= :: GetCustomEntityTypeResponse -> GetCustomEntityTypeResponse -> Bool
== :: GetCustomEntityTypeResponse -> GetCustomEntityTypeResponse -> Bool
$c== :: GetCustomEntityTypeResponse -> GetCustomEntityTypeResponse -> Bool
Prelude.Eq, ReadPrec [GetCustomEntityTypeResponse]
ReadPrec GetCustomEntityTypeResponse
Int -> ReadS GetCustomEntityTypeResponse
ReadS [GetCustomEntityTypeResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetCustomEntityTypeResponse]
$creadListPrec :: ReadPrec [GetCustomEntityTypeResponse]
readPrec :: ReadPrec GetCustomEntityTypeResponse
$creadPrec :: ReadPrec GetCustomEntityTypeResponse
readList :: ReadS [GetCustomEntityTypeResponse]
$creadList :: ReadS [GetCustomEntityTypeResponse]
readsPrec :: Int -> ReadS GetCustomEntityTypeResponse
$creadsPrec :: Int -> ReadS GetCustomEntityTypeResponse
Prelude.Read, Int -> GetCustomEntityTypeResponse -> ShowS
[GetCustomEntityTypeResponse] -> ShowS
GetCustomEntityTypeResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetCustomEntityTypeResponse] -> ShowS
$cshowList :: [GetCustomEntityTypeResponse] -> ShowS
show :: GetCustomEntityTypeResponse -> String
$cshow :: GetCustomEntityTypeResponse -> String
showsPrec :: Int -> GetCustomEntityTypeResponse -> ShowS
$cshowsPrec :: Int -> GetCustomEntityTypeResponse -> ShowS
Prelude.Show, forall x.
Rep GetCustomEntityTypeResponse x -> GetCustomEntityTypeResponse
forall x.
GetCustomEntityTypeResponse -> Rep GetCustomEntityTypeResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep GetCustomEntityTypeResponse x -> GetCustomEntityTypeResponse
$cfrom :: forall x.
GetCustomEntityTypeResponse -> Rep GetCustomEntityTypeResponse x
Prelude.Generic)

-- |
-- Create a value of 'GetCustomEntityTypeResponse' 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', 'getCustomEntityTypeResponse_contextWords' - A list of context words if specified when you created the custom
-- pattern. If none of these context words are found within the vicinity of
-- the regular expression the data will not be detected as sensitive data.
--
-- 'name', 'getCustomEntityTypeResponse_name' - The name of the custom pattern that you retrieved.
--
-- 'regexString', 'getCustomEntityTypeResponse_regexString' - A regular expression string that is used for detecting sensitive data in
-- a custom pattern.
--
-- 'httpStatus', 'getCustomEntityTypeResponse_httpStatus' - The response's http status code.
newGetCustomEntityTypeResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  GetCustomEntityTypeResponse
newGetCustomEntityTypeResponse :: Int -> GetCustomEntityTypeResponse
newGetCustomEntityTypeResponse Int
pHttpStatus_ =
  GetCustomEntityTypeResponse'
    { $sel:contextWords:GetCustomEntityTypeResponse' :: Maybe (NonEmpty Text)
contextWords =
        forall a. Maybe a
Prelude.Nothing,
      $sel:name:GetCustomEntityTypeResponse' :: Maybe Text
name = forall a. Maybe a
Prelude.Nothing,
      $sel:regexString:GetCustomEntityTypeResponse' :: Maybe Text
regexString = forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:GetCustomEntityTypeResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | A list of context words if specified when you created the custom
-- pattern. If none of these context words are found within the vicinity of
-- the regular expression the data will not be detected as sensitive data.
getCustomEntityTypeResponse_contextWords :: Lens.Lens' GetCustomEntityTypeResponse (Prelude.Maybe (Prelude.NonEmpty Prelude.Text))
getCustomEntityTypeResponse_contextWords :: Lens' GetCustomEntityTypeResponse (Maybe (NonEmpty Text))
getCustomEntityTypeResponse_contextWords = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetCustomEntityTypeResponse' {Maybe (NonEmpty Text)
contextWords :: Maybe (NonEmpty Text)
$sel:contextWords:GetCustomEntityTypeResponse' :: GetCustomEntityTypeResponse -> Maybe (NonEmpty Text)
contextWords} -> Maybe (NonEmpty Text)
contextWords) (\s :: GetCustomEntityTypeResponse
s@GetCustomEntityTypeResponse' {} Maybe (NonEmpty Text)
a -> GetCustomEntityTypeResponse
s {$sel:contextWords:GetCustomEntityTypeResponse' :: Maybe (NonEmpty Text)
contextWords = Maybe (NonEmpty Text)
a} :: GetCustomEntityTypeResponse) 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

-- | The name of the custom pattern that you retrieved.
getCustomEntityTypeResponse_name :: Lens.Lens' GetCustomEntityTypeResponse (Prelude.Maybe Prelude.Text)
getCustomEntityTypeResponse_name :: Lens' GetCustomEntityTypeResponse (Maybe Text)
getCustomEntityTypeResponse_name = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetCustomEntityTypeResponse' {Maybe Text
name :: Maybe Text
$sel:name:GetCustomEntityTypeResponse' :: GetCustomEntityTypeResponse -> Maybe Text
name} -> Maybe Text
name) (\s :: GetCustomEntityTypeResponse
s@GetCustomEntityTypeResponse' {} Maybe Text
a -> GetCustomEntityTypeResponse
s {$sel:name:GetCustomEntityTypeResponse' :: Maybe Text
name = Maybe Text
a} :: GetCustomEntityTypeResponse)

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

-- | The response's http status code.
getCustomEntityTypeResponse_httpStatus :: Lens.Lens' GetCustomEntityTypeResponse Prelude.Int
getCustomEntityTypeResponse_httpStatus :: Lens' GetCustomEntityTypeResponse Int
getCustomEntityTypeResponse_httpStatus = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetCustomEntityTypeResponse' {Int
httpStatus :: Int
$sel:httpStatus:GetCustomEntityTypeResponse' :: GetCustomEntityTypeResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: GetCustomEntityTypeResponse
s@GetCustomEntityTypeResponse' {} Int
a -> GetCustomEntityTypeResponse
s {$sel:httpStatus:GetCustomEntityTypeResponse' :: Int
httpStatus = Int
a} :: GetCustomEntityTypeResponse)

instance Prelude.NFData GetCustomEntityTypeResponse where
  rnf :: GetCustomEntityTypeResponse -> ()
rnf GetCustomEntityTypeResponse' {Int
Maybe (NonEmpty Text)
Maybe Text
httpStatus :: Int
regexString :: Maybe Text
name :: Maybe Text
contextWords :: Maybe (NonEmpty Text)
$sel:httpStatus:GetCustomEntityTypeResponse' :: GetCustomEntityTypeResponse -> Int
$sel:regexString:GetCustomEntityTypeResponse' :: GetCustomEntityTypeResponse -> Maybe Text
$sel:name:GetCustomEntityTypeResponse' :: GetCustomEntityTypeResponse -> Maybe Text
$sel:contextWords:GetCustomEntityTypeResponse' :: GetCustomEntityTypeResponse -> 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 Maybe Text
name
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
regexString
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus