{-# 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.DetectEntities
(
DetectEntities (..),
newDetectEntities,
detectEntities_languageCode,
detectEntities_endpointArn,
detectEntities_text,
DetectEntitiesResponse (..),
newDetectEntitiesResponse,
detectEntitiesResponse_entities,
detectEntitiesResponse_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 DetectEntities = DetectEntities'
{
DetectEntities -> Maybe LanguageCode
languageCode :: Prelude.Maybe LanguageCode,
DetectEntities -> Maybe Text
endpointArn :: Prelude.Maybe Prelude.Text,
DetectEntities -> Sensitive Text
text :: Core.Sensitive Prelude.Text
}
deriving (DetectEntities -> DetectEntities -> Bool
(DetectEntities -> DetectEntities -> Bool)
-> (DetectEntities -> DetectEntities -> Bool) -> Eq DetectEntities
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DetectEntities -> DetectEntities -> Bool
$c/= :: DetectEntities -> DetectEntities -> Bool
== :: DetectEntities -> DetectEntities -> Bool
$c== :: DetectEntities -> DetectEntities -> Bool
Prelude.Eq, Int -> DetectEntities -> ShowS
[DetectEntities] -> ShowS
DetectEntities -> String
(Int -> DetectEntities -> ShowS)
-> (DetectEntities -> String)
-> ([DetectEntities] -> ShowS)
-> Show DetectEntities
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DetectEntities] -> ShowS
$cshowList :: [DetectEntities] -> ShowS
show :: DetectEntities -> String
$cshow :: DetectEntities -> String
showsPrec :: Int -> DetectEntities -> ShowS
$cshowsPrec :: Int -> DetectEntities -> ShowS
Prelude.Show, (forall x. DetectEntities -> Rep DetectEntities x)
-> (forall x. Rep DetectEntities x -> DetectEntities)
-> Generic DetectEntities
forall x. Rep DetectEntities x -> DetectEntities
forall x. DetectEntities -> Rep DetectEntities x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DetectEntities x -> DetectEntities
$cfrom :: forall x. DetectEntities -> Rep DetectEntities x
Prelude.Generic)
newDetectEntities ::
Prelude.Text ->
DetectEntities
newDetectEntities :: Text -> DetectEntities
newDetectEntities Text
pText_ =
DetectEntities' :: Maybe LanguageCode
-> Maybe Text -> Sensitive Text -> DetectEntities
DetectEntities'
{ $sel:languageCode:DetectEntities' :: Maybe LanguageCode
languageCode = Maybe LanguageCode
forall a. Maybe a
Prelude.Nothing,
$sel:endpointArn:DetectEntities' :: Maybe Text
endpointArn = Maybe Text
forall a. Maybe a
Prelude.Nothing,
$sel:text:DetectEntities' :: Sensitive Text
text = Tagged Text (Identity Text)
-> Tagged (Sensitive Text) (Identity (Sensitive Text))
forall a. Iso' (Sensitive a) a
Core._Sensitive (Tagged Text (Identity Text)
-> Tagged (Sensitive Text) (Identity (Sensitive Text)))
-> Text -> Sensitive Text
forall t b. AReview t b -> b -> t
Lens.# Text
pText_
}
detectEntities_languageCode :: Lens.Lens' DetectEntities (Prelude.Maybe LanguageCode)
detectEntities_languageCode :: (Maybe LanguageCode -> f (Maybe LanguageCode))
-> DetectEntities -> f DetectEntities
detectEntities_languageCode = (DetectEntities -> Maybe LanguageCode)
-> (DetectEntities -> Maybe LanguageCode -> DetectEntities)
-> Lens
DetectEntities
DetectEntities
(Maybe LanguageCode)
(Maybe LanguageCode)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DetectEntities' {Maybe LanguageCode
languageCode :: Maybe LanguageCode
$sel:languageCode:DetectEntities' :: DetectEntities -> Maybe LanguageCode
languageCode} -> Maybe LanguageCode
languageCode) (\s :: DetectEntities
s@DetectEntities' {} Maybe LanguageCode
a -> DetectEntities
s {$sel:languageCode:DetectEntities' :: Maybe LanguageCode
languageCode = Maybe LanguageCode
a} :: DetectEntities)
detectEntities_endpointArn :: Lens.Lens' DetectEntities (Prelude.Maybe Prelude.Text)
detectEntities_endpointArn :: (Maybe Text -> f (Maybe Text))
-> DetectEntities -> f DetectEntities
detectEntities_endpointArn = (DetectEntities -> Maybe Text)
-> (DetectEntities -> Maybe Text -> DetectEntities)
-> Lens DetectEntities DetectEntities (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DetectEntities' {Maybe Text
endpointArn :: Maybe Text
$sel:endpointArn:DetectEntities' :: DetectEntities -> Maybe Text
endpointArn} -> Maybe Text
endpointArn) (\s :: DetectEntities
s@DetectEntities' {} Maybe Text
a -> DetectEntities
s {$sel:endpointArn:DetectEntities' :: Maybe Text
endpointArn = Maybe Text
a} :: DetectEntities)
detectEntities_text :: Lens.Lens' DetectEntities Prelude.Text
detectEntities_text :: (Text -> f Text) -> DetectEntities -> f DetectEntities
detectEntities_text = (DetectEntities -> Sensitive Text)
-> (DetectEntities -> Sensitive Text -> DetectEntities)
-> Lens
DetectEntities DetectEntities (Sensitive Text) (Sensitive Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DetectEntities' {Sensitive Text
text :: Sensitive Text
$sel:text:DetectEntities' :: DetectEntities -> Sensitive Text
text} -> Sensitive Text
text) (\s :: DetectEntities
s@DetectEntities' {} Sensitive Text
a -> DetectEntities
s {$sel:text:DetectEntities' :: Sensitive Text
text = Sensitive Text
a} :: DetectEntities) ((Sensitive Text -> f (Sensitive Text))
-> DetectEntities -> f DetectEntities)
-> ((Text -> f Text) -> Sensitive Text -> f (Sensitive Text))
-> (Text -> f Text)
-> DetectEntities
-> f DetectEntities
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (Text -> f Text) -> Sensitive Text -> f (Sensitive Text)
forall a. Iso' (Sensitive a) a
Core._Sensitive
instance Core.AWSRequest DetectEntities where
type
AWSResponse DetectEntities =
DetectEntitiesResponse
request :: DetectEntities -> Request DetectEntities
request = Service -> DetectEntities -> Request DetectEntities
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
response :: Logger
-> Service
-> Proxy DetectEntities
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse DetectEntities)))
response =
(Int
-> ResponseHeaders
-> Object
-> Either String (AWSResponse DetectEntities))
-> Logger
-> Service
-> Proxy DetectEntities
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse DetectEntities)))
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 [Entity] -> Int -> DetectEntitiesResponse
DetectEntitiesResponse'
(Maybe [Entity] -> Int -> DetectEntitiesResponse)
-> Either String (Maybe [Entity])
-> Either String (Int -> DetectEntitiesResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Either String (Maybe (Maybe [Entity]))
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"Entities" Either String (Maybe (Maybe [Entity]))
-> Maybe [Entity] -> Either String (Maybe [Entity])
forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ Maybe [Entity]
forall a. Monoid a => a
Prelude.mempty)
Either String (Int -> DetectEntitiesResponse)
-> Either String Int -> Either String DetectEntitiesResponse
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 DetectEntities
instance Prelude.NFData DetectEntities
instance Core.ToHeaders DetectEntities where
toHeaders :: DetectEntities -> ResponseHeaders
toHeaders =
ResponseHeaders -> DetectEntities -> 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.DetectEntities" ::
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 DetectEntities where
toJSON :: DetectEntities -> Value
toJSON DetectEntities' {Maybe Text
Maybe LanguageCode
Sensitive Text
text :: Sensitive Text
endpointArn :: Maybe Text
languageCode :: Maybe LanguageCode
$sel:text:DetectEntities' :: DetectEntities -> Sensitive Text
$sel:endpointArn:DetectEntities' :: DetectEntities -> Maybe Text
$sel:languageCode:DetectEntities' :: DetectEntities -> Maybe LanguageCode
..} =
[Pair] -> Value
Core.object
( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
[ (Text
"LanguageCode" Text -> LanguageCode -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (LanguageCode -> Pair) -> Maybe LanguageCode -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe LanguageCode
languageCode,
(Text
"EndpointArn" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
endpointArn,
Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"Text" Text -> Sensitive Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Sensitive Text
text)
]
)
instance Core.ToPath DetectEntities where
toPath :: DetectEntities -> ByteString
toPath = ByteString -> DetectEntities -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/"
instance Core.ToQuery DetectEntities where
toQuery :: DetectEntities -> QueryString
toQuery = QueryString -> DetectEntities -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
forall a. Monoid a => a
Prelude.mempty
data DetectEntitiesResponse = DetectEntitiesResponse'
{
DetectEntitiesResponse -> Maybe [Entity]
entities :: Prelude.Maybe [Entity],
DetectEntitiesResponse -> Int
httpStatus :: Prelude.Int
}
deriving (DetectEntitiesResponse -> DetectEntitiesResponse -> Bool
(DetectEntitiesResponse -> DetectEntitiesResponse -> Bool)
-> (DetectEntitiesResponse -> DetectEntitiesResponse -> Bool)
-> Eq DetectEntitiesResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DetectEntitiesResponse -> DetectEntitiesResponse -> Bool
$c/= :: DetectEntitiesResponse -> DetectEntitiesResponse -> Bool
== :: DetectEntitiesResponse -> DetectEntitiesResponse -> Bool
$c== :: DetectEntitiesResponse -> DetectEntitiesResponse -> Bool
Prelude.Eq, Int -> DetectEntitiesResponse -> ShowS
[DetectEntitiesResponse] -> ShowS
DetectEntitiesResponse -> String
(Int -> DetectEntitiesResponse -> ShowS)
-> (DetectEntitiesResponse -> String)
-> ([DetectEntitiesResponse] -> ShowS)
-> Show DetectEntitiesResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DetectEntitiesResponse] -> ShowS
$cshowList :: [DetectEntitiesResponse] -> ShowS
show :: DetectEntitiesResponse -> String
$cshow :: DetectEntitiesResponse -> String
showsPrec :: Int -> DetectEntitiesResponse -> ShowS
$cshowsPrec :: Int -> DetectEntitiesResponse -> ShowS
Prelude.Show, (forall x. DetectEntitiesResponse -> Rep DetectEntitiesResponse x)
-> (forall x.
Rep DetectEntitiesResponse x -> DetectEntitiesResponse)
-> Generic DetectEntitiesResponse
forall x. Rep DetectEntitiesResponse x -> DetectEntitiesResponse
forall x. DetectEntitiesResponse -> Rep DetectEntitiesResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DetectEntitiesResponse x -> DetectEntitiesResponse
$cfrom :: forall x. DetectEntitiesResponse -> Rep DetectEntitiesResponse x
Prelude.Generic)
newDetectEntitiesResponse ::
Prelude.Int ->
DetectEntitiesResponse
newDetectEntitiesResponse :: Int -> DetectEntitiesResponse
newDetectEntitiesResponse Int
pHttpStatus_ =
DetectEntitiesResponse' :: Maybe [Entity] -> Int -> DetectEntitiesResponse
DetectEntitiesResponse'
{ $sel:entities:DetectEntitiesResponse' :: Maybe [Entity]
entities = Maybe [Entity]
forall a. Maybe a
Prelude.Nothing,
$sel:httpStatus:DetectEntitiesResponse' :: Int
httpStatus = Int
pHttpStatus_
}
detectEntitiesResponse_entities :: Lens.Lens' DetectEntitiesResponse (Prelude.Maybe [Entity])
detectEntitiesResponse_entities :: (Maybe [Entity] -> f (Maybe [Entity]))
-> DetectEntitiesResponse -> f DetectEntitiesResponse
detectEntitiesResponse_entities = (DetectEntitiesResponse -> Maybe [Entity])
-> (DetectEntitiesResponse
-> Maybe [Entity] -> DetectEntitiesResponse)
-> Lens
DetectEntitiesResponse
DetectEntitiesResponse
(Maybe [Entity])
(Maybe [Entity])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DetectEntitiesResponse' {Maybe [Entity]
entities :: Maybe [Entity]
$sel:entities:DetectEntitiesResponse' :: DetectEntitiesResponse -> Maybe [Entity]
entities} -> Maybe [Entity]
entities) (\s :: DetectEntitiesResponse
s@DetectEntitiesResponse' {} Maybe [Entity]
a -> DetectEntitiesResponse
s {$sel:entities:DetectEntitiesResponse' :: Maybe [Entity]
entities = Maybe [Entity]
a} :: DetectEntitiesResponse) ((Maybe [Entity] -> f (Maybe [Entity]))
-> DetectEntitiesResponse -> f DetectEntitiesResponse)
-> ((Maybe [Entity] -> f (Maybe [Entity]))
-> Maybe [Entity] -> f (Maybe [Entity]))
-> (Maybe [Entity] -> f (Maybe [Entity]))
-> DetectEntitiesResponse
-> f DetectEntitiesResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Entity] [Entity] [Entity] [Entity]
-> Iso
(Maybe [Entity]) (Maybe [Entity]) (Maybe [Entity]) (Maybe [Entity])
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 [Entity] [Entity] [Entity] [Entity]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced
detectEntitiesResponse_httpStatus :: Lens.Lens' DetectEntitiesResponse Prelude.Int
detectEntitiesResponse_httpStatus :: (Int -> f Int)
-> DetectEntitiesResponse -> f DetectEntitiesResponse
detectEntitiesResponse_httpStatus = (DetectEntitiesResponse -> Int)
-> (DetectEntitiesResponse -> Int -> DetectEntitiesResponse)
-> Lens DetectEntitiesResponse DetectEntitiesResponse Int Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DetectEntitiesResponse' {Int
httpStatus :: Int
$sel:httpStatus:DetectEntitiesResponse' :: DetectEntitiesResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: DetectEntitiesResponse
s@DetectEntitiesResponse' {} Int
a -> DetectEntitiesResponse
s {$sel:httpStatus:DetectEntitiesResponse' :: Int
httpStatus = Int
a} :: DetectEntitiesResponse)
instance Prelude.NFData DetectEntitiesResponse