{-# 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.ClassifyDocument
(
ClassifyDocument (..),
newClassifyDocument,
classifyDocument_text,
classifyDocument_endpointArn,
ClassifyDocumentResponse (..),
newClassifyDocumentResponse,
classifyDocumentResponse_labels,
classifyDocumentResponse_classes,
classifyDocumentResponse_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 ClassifyDocument = ClassifyDocument'
{
ClassifyDocument -> Sensitive Text
text :: Core.Sensitive Prelude.Text,
ClassifyDocument -> Text
endpointArn :: Prelude.Text
}
deriving (ClassifyDocument -> ClassifyDocument -> Bool
(ClassifyDocument -> ClassifyDocument -> Bool)
-> (ClassifyDocument -> ClassifyDocument -> Bool)
-> Eq ClassifyDocument
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ClassifyDocument -> ClassifyDocument -> Bool
$c/= :: ClassifyDocument -> ClassifyDocument -> Bool
== :: ClassifyDocument -> ClassifyDocument -> Bool
$c== :: ClassifyDocument -> ClassifyDocument -> Bool
Prelude.Eq, Int -> ClassifyDocument -> ShowS
[ClassifyDocument] -> ShowS
ClassifyDocument -> String
(Int -> ClassifyDocument -> ShowS)
-> (ClassifyDocument -> String)
-> ([ClassifyDocument] -> ShowS)
-> Show ClassifyDocument
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ClassifyDocument] -> ShowS
$cshowList :: [ClassifyDocument] -> ShowS
show :: ClassifyDocument -> String
$cshow :: ClassifyDocument -> String
showsPrec :: Int -> ClassifyDocument -> ShowS
$cshowsPrec :: Int -> ClassifyDocument -> ShowS
Prelude.Show, (forall x. ClassifyDocument -> Rep ClassifyDocument x)
-> (forall x. Rep ClassifyDocument x -> ClassifyDocument)
-> Generic ClassifyDocument
forall x. Rep ClassifyDocument x -> ClassifyDocument
forall x. ClassifyDocument -> Rep ClassifyDocument x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ClassifyDocument x -> ClassifyDocument
$cfrom :: forall x. ClassifyDocument -> Rep ClassifyDocument x
Prelude.Generic)
newClassifyDocument ::
Prelude.Text ->
Prelude.Text ->
ClassifyDocument
newClassifyDocument :: Text -> Text -> ClassifyDocument
newClassifyDocument Text
pText_ Text
pEndpointArn_ =
ClassifyDocument' :: Sensitive Text -> Text -> ClassifyDocument
ClassifyDocument'
{ $sel:text:ClassifyDocument' :: 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_,
$sel:endpointArn:ClassifyDocument' :: Text
endpointArn = Text
pEndpointArn_
}
classifyDocument_text :: Lens.Lens' ClassifyDocument Prelude.Text
classifyDocument_text :: (Text -> f Text) -> ClassifyDocument -> f ClassifyDocument
classifyDocument_text = (ClassifyDocument -> Sensitive Text)
-> (ClassifyDocument -> Sensitive Text -> ClassifyDocument)
-> Lens
ClassifyDocument ClassifyDocument (Sensitive Text) (Sensitive Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ClassifyDocument' {Sensitive Text
text :: Sensitive Text
$sel:text:ClassifyDocument' :: ClassifyDocument -> Sensitive Text
text} -> Sensitive Text
text) (\s :: ClassifyDocument
s@ClassifyDocument' {} Sensitive Text
a -> ClassifyDocument
s {$sel:text:ClassifyDocument' :: Sensitive Text
text = Sensitive Text
a} :: ClassifyDocument) ((Sensitive Text -> f (Sensitive Text))
-> ClassifyDocument -> f ClassifyDocument)
-> ((Text -> f Text) -> Sensitive Text -> f (Sensitive Text))
-> (Text -> f Text)
-> ClassifyDocument
-> f ClassifyDocument
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
classifyDocument_endpointArn :: Lens.Lens' ClassifyDocument Prelude.Text
classifyDocument_endpointArn :: (Text -> f Text) -> ClassifyDocument -> f ClassifyDocument
classifyDocument_endpointArn = (ClassifyDocument -> Text)
-> (ClassifyDocument -> Text -> ClassifyDocument)
-> Lens ClassifyDocument ClassifyDocument Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ClassifyDocument' {Text
endpointArn :: Text
$sel:endpointArn:ClassifyDocument' :: ClassifyDocument -> Text
endpointArn} -> Text
endpointArn) (\s :: ClassifyDocument
s@ClassifyDocument' {} Text
a -> ClassifyDocument
s {$sel:endpointArn:ClassifyDocument' :: Text
endpointArn = Text
a} :: ClassifyDocument)
instance Core.AWSRequest ClassifyDocument where
type
AWSResponse ClassifyDocument =
ClassifyDocumentResponse
request :: ClassifyDocument -> Request ClassifyDocument
request = Service -> ClassifyDocument -> Request ClassifyDocument
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
response :: Logger
-> Service
-> Proxy ClassifyDocument
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse ClassifyDocument)))
response =
(Int
-> ResponseHeaders
-> Object
-> Either String (AWSResponse ClassifyDocument))
-> Logger
-> Service
-> Proxy ClassifyDocument
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse ClassifyDocument)))
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 [DocumentLabel]
-> Maybe [DocumentClass] -> Int -> ClassifyDocumentResponse
ClassifyDocumentResponse'
(Maybe [DocumentLabel]
-> Maybe [DocumentClass] -> Int -> ClassifyDocumentResponse)
-> Either String (Maybe [DocumentLabel])
-> Either
String (Maybe [DocumentClass] -> Int -> ClassifyDocumentResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Either String (Maybe (Maybe [DocumentLabel]))
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"Labels" Either String (Maybe (Maybe [DocumentLabel]))
-> Maybe [DocumentLabel] -> Either String (Maybe [DocumentLabel])
forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ Maybe [DocumentLabel]
forall a. Monoid a => a
Prelude.mempty)
Either
String (Maybe [DocumentClass] -> Int -> ClassifyDocumentResponse)
-> Either String (Maybe [DocumentClass])
-> Either String (Int -> ClassifyDocumentResponse)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Either String (Maybe (Maybe [DocumentClass]))
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"Classes" Either String (Maybe (Maybe [DocumentClass]))
-> Maybe [DocumentClass] -> Either String (Maybe [DocumentClass])
forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ Maybe [DocumentClass]
forall a. Monoid a => a
Prelude.mempty)
Either String (Int -> ClassifyDocumentResponse)
-> Either String Int -> Either String ClassifyDocumentResponse
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 ClassifyDocument
instance Prelude.NFData ClassifyDocument
instance Core.ToHeaders ClassifyDocument where
toHeaders :: ClassifyDocument -> ResponseHeaders
toHeaders =
ResponseHeaders -> ClassifyDocument -> 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.ClassifyDocument" ::
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 ClassifyDocument where
toJSON :: ClassifyDocument -> Value
toJSON ClassifyDocument' {Text
Sensitive Text
endpointArn :: Text
text :: Sensitive Text
$sel:endpointArn:ClassifyDocument' :: ClassifyDocument -> Text
$sel:text:ClassifyDocument' :: ClassifyDocument -> Sensitive 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 -> Sensitive Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Sensitive Text
text),
Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"EndpointArn" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
endpointArn)
]
)
instance Core.ToPath ClassifyDocument where
toPath :: ClassifyDocument -> ByteString
toPath = ByteString -> ClassifyDocument -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/"
instance Core.ToQuery ClassifyDocument where
toQuery :: ClassifyDocument -> QueryString
toQuery = QueryString -> ClassifyDocument -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
forall a. Monoid a => a
Prelude.mempty
data ClassifyDocumentResponse = ClassifyDocumentResponse'
{
ClassifyDocumentResponse -> Maybe [DocumentLabel]
labels :: Prelude.Maybe [DocumentLabel],
ClassifyDocumentResponse -> Maybe [DocumentClass]
classes :: Prelude.Maybe [DocumentClass],
ClassifyDocumentResponse -> Int
httpStatus :: Prelude.Int
}
deriving (ClassifyDocumentResponse -> ClassifyDocumentResponse -> Bool
(ClassifyDocumentResponse -> ClassifyDocumentResponse -> Bool)
-> (ClassifyDocumentResponse -> ClassifyDocumentResponse -> Bool)
-> Eq ClassifyDocumentResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ClassifyDocumentResponse -> ClassifyDocumentResponse -> Bool
$c/= :: ClassifyDocumentResponse -> ClassifyDocumentResponse -> Bool
== :: ClassifyDocumentResponse -> ClassifyDocumentResponse -> Bool
$c== :: ClassifyDocumentResponse -> ClassifyDocumentResponse -> Bool
Prelude.Eq, Int -> ClassifyDocumentResponse -> ShowS
[ClassifyDocumentResponse] -> ShowS
ClassifyDocumentResponse -> String
(Int -> ClassifyDocumentResponse -> ShowS)
-> (ClassifyDocumentResponse -> String)
-> ([ClassifyDocumentResponse] -> ShowS)
-> Show ClassifyDocumentResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ClassifyDocumentResponse] -> ShowS
$cshowList :: [ClassifyDocumentResponse] -> ShowS
show :: ClassifyDocumentResponse -> String
$cshow :: ClassifyDocumentResponse -> String
showsPrec :: Int -> ClassifyDocumentResponse -> ShowS
$cshowsPrec :: Int -> ClassifyDocumentResponse -> ShowS
Prelude.Show, (forall x.
ClassifyDocumentResponse -> Rep ClassifyDocumentResponse x)
-> (forall x.
Rep ClassifyDocumentResponse x -> ClassifyDocumentResponse)
-> Generic ClassifyDocumentResponse
forall x.
Rep ClassifyDocumentResponse x -> ClassifyDocumentResponse
forall x.
ClassifyDocumentResponse -> Rep ClassifyDocumentResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep ClassifyDocumentResponse x -> ClassifyDocumentResponse
$cfrom :: forall x.
ClassifyDocumentResponse -> Rep ClassifyDocumentResponse x
Prelude.Generic)
newClassifyDocumentResponse ::
Prelude.Int ->
ClassifyDocumentResponse
newClassifyDocumentResponse :: Int -> ClassifyDocumentResponse
newClassifyDocumentResponse Int
pHttpStatus_ =
ClassifyDocumentResponse' :: Maybe [DocumentLabel]
-> Maybe [DocumentClass] -> Int -> ClassifyDocumentResponse
ClassifyDocumentResponse'
{ $sel:labels:ClassifyDocumentResponse' :: Maybe [DocumentLabel]
labels = Maybe [DocumentLabel]
forall a. Maybe a
Prelude.Nothing,
$sel:classes:ClassifyDocumentResponse' :: Maybe [DocumentClass]
classes = Maybe [DocumentClass]
forall a. Maybe a
Prelude.Nothing,
$sel:httpStatus:ClassifyDocumentResponse' :: Int
httpStatus = Int
pHttpStatus_
}
classifyDocumentResponse_labels :: Lens.Lens' ClassifyDocumentResponse (Prelude.Maybe [DocumentLabel])
classifyDocumentResponse_labels :: (Maybe [DocumentLabel] -> f (Maybe [DocumentLabel]))
-> ClassifyDocumentResponse -> f ClassifyDocumentResponse
classifyDocumentResponse_labels = (ClassifyDocumentResponse -> Maybe [DocumentLabel])
-> (ClassifyDocumentResponse
-> Maybe [DocumentLabel] -> ClassifyDocumentResponse)
-> Lens
ClassifyDocumentResponse
ClassifyDocumentResponse
(Maybe [DocumentLabel])
(Maybe [DocumentLabel])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ClassifyDocumentResponse' {Maybe [DocumentLabel]
labels :: Maybe [DocumentLabel]
$sel:labels:ClassifyDocumentResponse' :: ClassifyDocumentResponse -> Maybe [DocumentLabel]
labels} -> Maybe [DocumentLabel]
labels) (\s :: ClassifyDocumentResponse
s@ClassifyDocumentResponse' {} Maybe [DocumentLabel]
a -> ClassifyDocumentResponse
s {$sel:labels:ClassifyDocumentResponse' :: Maybe [DocumentLabel]
labels = Maybe [DocumentLabel]
a} :: ClassifyDocumentResponse) ((Maybe [DocumentLabel] -> f (Maybe [DocumentLabel]))
-> ClassifyDocumentResponse -> f ClassifyDocumentResponse)
-> ((Maybe [DocumentLabel] -> f (Maybe [DocumentLabel]))
-> Maybe [DocumentLabel] -> f (Maybe [DocumentLabel]))
-> (Maybe [DocumentLabel] -> f (Maybe [DocumentLabel]))
-> ClassifyDocumentResponse
-> f ClassifyDocumentResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
[DocumentLabel] [DocumentLabel] [DocumentLabel] [DocumentLabel]
-> Iso
(Maybe [DocumentLabel])
(Maybe [DocumentLabel])
(Maybe [DocumentLabel])
(Maybe [DocumentLabel])
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
[DocumentLabel] [DocumentLabel] [DocumentLabel] [DocumentLabel]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced
classifyDocumentResponse_classes :: Lens.Lens' ClassifyDocumentResponse (Prelude.Maybe [DocumentClass])
classifyDocumentResponse_classes :: (Maybe [DocumentClass] -> f (Maybe [DocumentClass]))
-> ClassifyDocumentResponse -> f ClassifyDocumentResponse
classifyDocumentResponse_classes = (ClassifyDocumentResponse -> Maybe [DocumentClass])
-> (ClassifyDocumentResponse
-> Maybe [DocumentClass] -> ClassifyDocumentResponse)
-> Lens
ClassifyDocumentResponse
ClassifyDocumentResponse
(Maybe [DocumentClass])
(Maybe [DocumentClass])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ClassifyDocumentResponse' {Maybe [DocumentClass]
classes :: Maybe [DocumentClass]
$sel:classes:ClassifyDocumentResponse' :: ClassifyDocumentResponse -> Maybe [DocumentClass]
classes} -> Maybe [DocumentClass]
classes) (\s :: ClassifyDocumentResponse
s@ClassifyDocumentResponse' {} Maybe [DocumentClass]
a -> ClassifyDocumentResponse
s {$sel:classes:ClassifyDocumentResponse' :: Maybe [DocumentClass]
classes = Maybe [DocumentClass]
a} :: ClassifyDocumentResponse) ((Maybe [DocumentClass] -> f (Maybe [DocumentClass]))
-> ClassifyDocumentResponse -> f ClassifyDocumentResponse)
-> ((Maybe [DocumentClass] -> f (Maybe [DocumentClass]))
-> Maybe [DocumentClass] -> f (Maybe [DocumentClass]))
-> (Maybe [DocumentClass] -> f (Maybe [DocumentClass]))
-> ClassifyDocumentResponse
-> f ClassifyDocumentResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
[DocumentClass] [DocumentClass] [DocumentClass] [DocumentClass]
-> Iso
(Maybe [DocumentClass])
(Maybe [DocumentClass])
(Maybe [DocumentClass])
(Maybe [DocumentClass])
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
[DocumentClass] [DocumentClass] [DocumentClass] [DocumentClass]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced
classifyDocumentResponse_httpStatus :: Lens.Lens' ClassifyDocumentResponse Prelude.Int
classifyDocumentResponse_httpStatus :: (Int -> f Int)
-> ClassifyDocumentResponse -> f ClassifyDocumentResponse
classifyDocumentResponse_httpStatus = (ClassifyDocumentResponse -> Int)
-> (ClassifyDocumentResponse -> Int -> ClassifyDocumentResponse)
-> Lens ClassifyDocumentResponse ClassifyDocumentResponse Int Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ClassifyDocumentResponse' {Int
httpStatus :: Int
$sel:httpStatus:ClassifyDocumentResponse' :: ClassifyDocumentResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: ClassifyDocumentResponse
s@ClassifyDocumentResponse' {} Int
a -> ClassifyDocumentResponse
s {$sel:httpStatus:ClassifyDocumentResponse' :: Int
httpStatus = Int
a} :: ClassifyDocumentResponse)
instance Prelude.NFData ClassifyDocumentResponse