{-# 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 #-}
module Amazonka.Comprehend.DetectPiiEntities
(
DetectPiiEntities (..),
newDetectPiiEntities,
detectPiiEntities_text,
detectPiiEntities_languageCode,
DetectPiiEntitiesResponse (..),
newDetectPiiEntitiesResponse,
detectPiiEntitiesResponse_entities,
detectPiiEntitiesResponse_httpStatus,
)
where
import Amazonka.Comprehend.Types
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response
data DetectPiiEntities = DetectPiiEntities'
{
DetectPiiEntities -> Text
text :: Prelude.Text,
DetectPiiEntities -> LanguageCode
languageCode :: LanguageCode
}
deriving (DetectPiiEntities -> DetectPiiEntities -> Bool
(DetectPiiEntities -> DetectPiiEntities -> Bool)
-> (DetectPiiEntities -> DetectPiiEntities -> Bool)
-> Eq DetectPiiEntities
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DetectPiiEntities -> DetectPiiEntities -> Bool
$c/= :: DetectPiiEntities -> DetectPiiEntities -> Bool
== :: DetectPiiEntities -> DetectPiiEntities -> Bool
$c== :: DetectPiiEntities -> DetectPiiEntities -> Bool
Prelude.Eq, ReadPrec [DetectPiiEntities]
ReadPrec DetectPiiEntities
Int -> ReadS DetectPiiEntities
ReadS [DetectPiiEntities]
(Int -> ReadS DetectPiiEntities)
-> ReadS [DetectPiiEntities]
-> ReadPrec DetectPiiEntities
-> ReadPrec [DetectPiiEntities]
-> Read DetectPiiEntities
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DetectPiiEntities]
$creadListPrec :: ReadPrec [DetectPiiEntities]
readPrec :: ReadPrec DetectPiiEntities
$creadPrec :: ReadPrec DetectPiiEntities
readList :: ReadS [DetectPiiEntities]
$creadList :: ReadS [DetectPiiEntities]
readsPrec :: Int -> ReadS DetectPiiEntities
$creadsPrec :: Int -> ReadS DetectPiiEntities
Prelude.Read, Int -> DetectPiiEntities -> ShowS
[DetectPiiEntities] -> ShowS
DetectPiiEntities -> String
(Int -> DetectPiiEntities -> ShowS)
-> (DetectPiiEntities -> String)
-> ([DetectPiiEntities] -> ShowS)
-> Show DetectPiiEntities
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DetectPiiEntities] -> ShowS
$cshowList :: [DetectPiiEntities] -> ShowS
show :: DetectPiiEntities -> String
$cshow :: DetectPiiEntities -> String
showsPrec :: Int -> DetectPiiEntities -> ShowS
$cshowsPrec :: Int -> DetectPiiEntities -> ShowS
Prelude.Show, (forall x. DetectPiiEntities -> Rep DetectPiiEntities x)
-> (forall x. Rep DetectPiiEntities x -> DetectPiiEntities)
-> Generic DetectPiiEntities
forall x. Rep DetectPiiEntities x -> DetectPiiEntities
forall x. DetectPiiEntities -> Rep DetectPiiEntities x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DetectPiiEntities x -> DetectPiiEntities
$cfrom :: forall x. DetectPiiEntities -> Rep DetectPiiEntities x
Prelude.Generic)
newDetectPiiEntities ::
Prelude.Text ->
LanguageCode ->
DetectPiiEntities
newDetectPiiEntities :: Text -> LanguageCode -> DetectPiiEntities
newDetectPiiEntities Text
pText_ LanguageCode
pLanguageCode_ =
DetectPiiEntities' :: Text -> LanguageCode -> DetectPiiEntities
DetectPiiEntities'
{ $sel:text:DetectPiiEntities' :: Text
text = Text
pText_,
$sel:languageCode:DetectPiiEntities' :: LanguageCode
languageCode = LanguageCode
pLanguageCode_
}
detectPiiEntities_text :: Lens.Lens' DetectPiiEntities Prelude.Text
detectPiiEntities_text :: (Text -> f Text) -> DetectPiiEntities -> f DetectPiiEntities
detectPiiEntities_text = (DetectPiiEntities -> Text)
-> (DetectPiiEntities -> Text -> DetectPiiEntities)
-> Lens DetectPiiEntities DetectPiiEntities Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DetectPiiEntities' {Text
text :: Text
$sel:text:DetectPiiEntities' :: DetectPiiEntities -> Text
text} -> Text
text) (\s :: DetectPiiEntities
s@DetectPiiEntities' {} Text
a -> DetectPiiEntities
s {$sel:text:DetectPiiEntities' :: Text
text = Text
a} :: DetectPiiEntities)
detectPiiEntities_languageCode :: Lens.Lens' DetectPiiEntities LanguageCode
detectPiiEntities_languageCode :: (LanguageCode -> f LanguageCode)
-> DetectPiiEntities -> f DetectPiiEntities
detectPiiEntities_languageCode = (DetectPiiEntities -> LanguageCode)
-> (DetectPiiEntities -> LanguageCode -> DetectPiiEntities)
-> Lens
DetectPiiEntities DetectPiiEntities LanguageCode LanguageCode
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DetectPiiEntities' {LanguageCode
languageCode :: LanguageCode
$sel:languageCode:DetectPiiEntities' :: DetectPiiEntities -> LanguageCode
languageCode} -> LanguageCode
languageCode) (\s :: DetectPiiEntities
s@DetectPiiEntities' {} LanguageCode
a -> DetectPiiEntities
s {$sel:languageCode:DetectPiiEntities' :: LanguageCode
languageCode = LanguageCode
a} :: DetectPiiEntities)
instance Core.AWSRequest DetectPiiEntities where
type
AWSResponse DetectPiiEntities =
DetectPiiEntitiesResponse
request :: DetectPiiEntities -> Request DetectPiiEntities
request = Service -> DetectPiiEntities -> Request DetectPiiEntities
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
response :: Logger
-> Service
-> Proxy DetectPiiEntities
-> ClientResponse ClientBody
-> m (Either
Error (ClientResponse (AWSResponse DetectPiiEntities)))
response =
(Int
-> ResponseHeaders
-> Object
-> Either String (AWSResponse DetectPiiEntities))
-> Logger
-> Service
-> Proxy DetectPiiEntities
-> ClientResponse ClientBody
-> m (Either
Error (ClientResponse (AWSResponse DetectPiiEntities)))
forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> Object -> Either String (AWSResponse a))
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveJSON
( \Int
s ResponseHeaders
h Object
x ->
Maybe [PiiEntity] -> Int -> DetectPiiEntitiesResponse
DetectPiiEntitiesResponse'
(Maybe [PiiEntity] -> Int -> DetectPiiEntitiesResponse)
-> Either String (Maybe [PiiEntity])
-> Either String (Int -> DetectPiiEntitiesResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Either String (Maybe (Maybe [PiiEntity]))
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"Entities" Either String (Maybe (Maybe [PiiEntity]))
-> Maybe [PiiEntity] -> Either String (Maybe [PiiEntity])
forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ Maybe [PiiEntity]
forall a. Monoid a => a
Prelude.mempty)
Either String (Int -> DetectPiiEntitiesResponse)
-> Either String Int -> Either String DetectPiiEntitiesResponse
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Int -> Either String Int
forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (Int -> Int
forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
)
instance Prelude.Hashable DetectPiiEntities
instance Prelude.NFData DetectPiiEntities
instance Core.ToHeaders DetectPiiEntities where
toHeaders :: DetectPiiEntities -> ResponseHeaders
toHeaders =
ResponseHeaders -> DetectPiiEntities -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const
( [ResponseHeaders] -> ResponseHeaders
forall a. Monoid a => [a] -> a
Prelude.mconcat
[ HeaderName
"X-Amz-Target"
HeaderName -> ByteString -> ResponseHeaders
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Core.=# ( ByteString
"Comprehend_20171127.DetectPiiEntities" ::
Prelude.ByteString
),
HeaderName
"Content-Type"
HeaderName -> ByteString -> ResponseHeaders
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Core.=# ( ByteString
"application/x-amz-json-1.1" ::
Prelude.ByteString
)
]
)
instance Core.ToJSON DetectPiiEntities where
toJSON :: DetectPiiEntities -> Value
toJSON DetectPiiEntities' {Text
LanguageCode
languageCode :: LanguageCode
text :: Text
$sel:languageCode:DetectPiiEntities' :: DetectPiiEntities -> LanguageCode
$sel:text:DetectPiiEntities' :: DetectPiiEntities -> Text
..} =
[Pair] -> Value
Core.object
( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
[ Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"Text" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
text),
Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"LanguageCode" Text -> LanguageCode -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= LanguageCode
languageCode)
]
)
instance Core.ToPath DetectPiiEntities where
toPath :: DetectPiiEntities -> ByteString
toPath = ByteString -> DetectPiiEntities -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/"
instance Core.ToQuery DetectPiiEntities where
toQuery :: DetectPiiEntities -> QueryString
toQuery = QueryString -> DetectPiiEntities -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
forall a. Monoid a => a
Prelude.mempty
data DetectPiiEntitiesResponse = DetectPiiEntitiesResponse'
{
DetectPiiEntitiesResponse -> Maybe [PiiEntity]
entities :: Prelude.Maybe [PiiEntity],
DetectPiiEntitiesResponse -> Int
httpStatus :: Prelude.Int
}
deriving (DetectPiiEntitiesResponse -> DetectPiiEntitiesResponse -> Bool
(DetectPiiEntitiesResponse -> DetectPiiEntitiesResponse -> Bool)
-> (DetectPiiEntitiesResponse -> DetectPiiEntitiesResponse -> Bool)
-> Eq DetectPiiEntitiesResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DetectPiiEntitiesResponse -> DetectPiiEntitiesResponse -> Bool
$c/= :: DetectPiiEntitiesResponse -> DetectPiiEntitiesResponse -> Bool
== :: DetectPiiEntitiesResponse -> DetectPiiEntitiesResponse -> Bool
$c== :: DetectPiiEntitiesResponse -> DetectPiiEntitiesResponse -> Bool
Prelude.Eq, ReadPrec [DetectPiiEntitiesResponse]
ReadPrec DetectPiiEntitiesResponse
Int -> ReadS DetectPiiEntitiesResponse
ReadS [DetectPiiEntitiesResponse]
(Int -> ReadS DetectPiiEntitiesResponse)
-> ReadS [DetectPiiEntitiesResponse]
-> ReadPrec DetectPiiEntitiesResponse
-> ReadPrec [DetectPiiEntitiesResponse]
-> Read DetectPiiEntitiesResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DetectPiiEntitiesResponse]
$creadListPrec :: ReadPrec [DetectPiiEntitiesResponse]
readPrec :: ReadPrec DetectPiiEntitiesResponse
$creadPrec :: ReadPrec DetectPiiEntitiesResponse
readList :: ReadS [DetectPiiEntitiesResponse]
$creadList :: ReadS [DetectPiiEntitiesResponse]
readsPrec :: Int -> ReadS DetectPiiEntitiesResponse
$creadsPrec :: Int -> ReadS DetectPiiEntitiesResponse
Prelude.Read, Int -> DetectPiiEntitiesResponse -> ShowS
[DetectPiiEntitiesResponse] -> ShowS
DetectPiiEntitiesResponse -> String
(Int -> DetectPiiEntitiesResponse -> ShowS)
-> (DetectPiiEntitiesResponse -> String)
-> ([DetectPiiEntitiesResponse] -> ShowS)
-> Show DetectPiiEntitiesResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DetectPiiEntitiesResponse] -> ShowS
$cshowList :: [DetectPiiEntitiesResponse] -> ShowS
show :: DetectPiiEntitiesResponse -> String
$cshow :: DetectPiiEntitiesResponse -> String
showsPrec :: Int -> DetectPiiEntitiesResponse -> ShowS
$cshowsPrec :: Int -> DetectPiiEntitiesResponse -> ShowS
Prelude.Show, (forall x.
DetectPiiEntitiesResponse -> Rep DetectPiiEntitiesResponse x)
-> (forall x.
Rep DetectPiiEntitiesResponse x -> DetectPiiEntitiesResponse)
-> Generic DetectPiiEntitiesResponse
forall x.
Rep DetectPiiEntitiesResponse x -> DetectPiiEntitiesResponse
forall x.
DetectPiiEntitiesResponse -> Rep DetectPiiEntitiesResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep DetectPiiEntitiesResponse x -> DetectPiiEntitiesResponse
$cfrom :: forall x.
DetectPiiEntitiesResponse -> Rep DetectPiiEntitiesResponse x
Prelude.Generic)
newDetectPiiEntitiesResponse ::
Prelude.Int ->
DetectPiiEntitiesResponse
newDetectPiiEntitiesResponse :: Int -> DetectPiiEntitiesResponse
newDetectPiiEntitiesResponse Int
pHttpStatus_ =
DetectPiiEntitiesResponse' :: Maybe [PiiEntity] -> Int -> DetectPiiEntitiesResponse
DetectPiiEntitiesResponse'
{ $sel:entities:DetectPiiEntitiesResponse' :: Maybe [PiiEntity]
entities =
Maybe [PiiEntity]
forall a. Maybe a
Prelude.Nothing,
$sel:httpStatus:DetectPiiEntitiesResponse' :: Int
httpStatus = Int
pHttpStatus_
}
detectPiiEntitiesResponse_entities :: Lens.Lens' DetectPiiEntitiesResponse (Prelude.Maybe [PiiEntity])
detectPiiEntitiesResponse_entities :: (Maybe [PiiEntity] -> f (Maybe [PiiEntity]))
-> DetectPiiEntitiesResponse -> f DetectPiiEntitiesResponse
detectPiiEntitiesResponse_entities = (DetectPiiEntitiesResponse -> Maybe [PiiEntity])
-> (DetectPiiEntitiesResponse
-> Maybe [PiiEntity] -> DetectPiiEntitiesResponse)
-> Lens
DetectPiiEntitiesResponse
DetectPiiEntitiesResponse
(Maybe [PiiEntity])
(Maybe [PiiEntity])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DetectPiiEntitiesResponse' {Maybe [PiiEntity]
entities :: Maybe [PiiEntity]
$sel:entities:DetectPiiEntitiesResponse' :: DetectPiiEntitiesResponse -> Maybe [PiiEntity]
entities} -> Maybe [PiiEntity]
entities) (\s :: DetectPiiEntitiesResponse
s@DetectPiiEntitiesResponse' {} Maybe [PiiEntity]
a -> DetectPiiEntitiesResponse
s {$sel:entities:DetectPiiEntitiesResponse' :: Maybe [PiiEntity]
entities = Maybe [PiiEntity]
a} :: DetectPiiEntitiesResponse) ((Maybe [PiiEntity] -> f (Maybe [PiiEntity]))
-> DetectPiiEntitiesResponse -> f DetectPiiEntitiesResponse)
-> ((Maybe [PiiEntity] -> f (Maybe [PiiEntity]))
-> Maybe [PiiEntity] -> f (Maybe [PiiEntity]))
-> (Maybe [PiiEntity] -> f (Maybe [PiiEntity]))
-> DetectPiiEntitiesResponse
-> f DetectPiiEntitiesResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [PiiEntity] [PiiEntity] [PiiEntity] [PiiEntity]
-> Iso
(Maybe [PiiEntity])
(Maybe [PiiEntity])
(Maybe [PiiEntity])
(Maybe [PiiEntity])
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 [PiiEntity] [PiiEntity] [PiiEntity] [PiiEntity]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced
detectPiiEntitiesResponse_httpStatus :: Lens.Lens' DetectPiiEntitiesResponse Prelude.Int
detectPiiEntitiesResponse_httpStatus :: (Int -> f Int)
-> DetectPiiEntitiesResponse -> f DetectPiiEntitiesResponse
detectPiiEntitiesResponse_httpStatus = (DetectPiiEntitiesResponse -> Int)
-> (DetectPiiEntitiesResponse -> Int -> DetectPiiEntitiesResponse)
-> Lens DetectPiiEntitiesResponse DetectPiiEntitiesResponse Int Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DetectPiiEntitiesResponse' {Int
httpStatus :: Int
$sel:httpStatus:DetectPiiEntitiesResponse' :: DetectPiiEntitiesResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: DetectPiiEntitiesResponse
s@DetectPiiEntitiesResponse' {} Int
a -> DetectPiiEntitiesResponse
s {$sel:httpStatus:DetectPiiEntitiesResponse' :: Int
httpStatus = Int
a} :: DetectPiiEntitiesResponse)
instance Prelude.NFData DetectPiiEntitiesResponse