{-# 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.Textract.DetectDocumentText
(
DetectDocumentText (..),
newDetectDocumentText,
detectDocumentText_document,
DetectDocumentTextResponse (..),
newDetectDocumentTextResponse,
detectDocumentTextResponse_documentMetadata,
detectDocumentTextResponse_blocks,
detectDocumentTextResponse_detectDocumentTextModelVersion,
detectDocumentTextResponse_httpStatus,
)
where
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
import Amazonka.Textract.Types
data DetectDocumentText = DetectDocumentText'
{
DetectDocumentText -> Document
document :: Document
}
deriving (DetectDocumentText -> DetectDocumentText -> Bool
(DetectDocumentText -> DetectDocumentText -> Bool)
-> (DetectDocumentText -> DetectDocumentText -> Bool)
-> Eq DetectDocumentText
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DetectDocumentText -> DetectDocumentText -> Bool
$c/= :: DetectDocumentText -> DetectDocumentText -> Bool
== :: DetectDocumentText -> DetectDocumentText -> Bool
$c== :: DetectDocumentText -> DetectDocumentText -> Bool
Prelude.Eq, ReadPrec [DetectDocumentText]
ReadPrec DetectDocumentText
Int -> ReadS DetectDocumentText
ReadS [DetectDocumentText]
(Int -> ReadS DetectDocumentText)
-> ReadS [DetectDocumentText]
-> ReadPrec DetectDocumentText
-> ReadPrec [DetectDocumentText]
-> Read DetectDocumentText
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DetectDocumentText]
$creadListPrec :: ReadPrec [DetectDocumentText]
readPrec :: ReadPrec DetectDocumentText
$creadPrec :: ReadPrec DetectDocumentText
readList :: ReadS [DetectDocumentText]
$creadList :: ReadS [DetectDocumentText]
readsPrec :: Int -> ReadS DetectDocumentText
$creadsPrec :: Int -> ReadS DetectDocumentText
Prelude.Read, Int -> DetectDocumentText -> ShowS
[DetectDocumentText] -> ShowS
DetectDocumentText -> String
(Int -> DetectDocumentText -> ShowS)
-> (DetectDocumentText -> String)
-> ([DetectDocumentText] -> ShowS)
-> Show DetectDocumentText
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DetectDocumentText] -> ShowS
$cshowList :: [DetectDocumentText] -> ShowS
show :: DetectDocumentText -> String
$cshow :: DetectDocumentText -> String
showsPrec :: Int -> DetectDocumentText -> ShowS
$cshowsPrec :: Int -> DetectDocumentText -> ShowS
Prelude.Show, (forall x. DetectDocumentText -> Rep DetectDocumentText x)
-> (forall x. Rep DetectDocumentText x -> DetectDocumentText)
-> Generic DetectDocumentText
forall x. Rep DetectDocumentText x -> DetectDocumentText
forall x. DetectDocumentText -> Rep DetectDocumentText x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DetectDocumentText x -> DetectDocumentText
$cfrom :: forall x. DetectDocumentText -> Rep DetectDocumentText x
Prelude.Generic)
newDetectDocumentText ::
Document ->
DetectDocumentText
newDetectDocumentText :: Document -> DetectDocumentText
newDetectDocumentText Document
pDocument_ =
DetectDocumentText' :: Document -> DetectDocumentText
DetectDocumentText' {$sel:document:DetectDocumentText' :: Document
document = Document
pDocument_}
detectDocumentText_document :: Lens.Lens' DetectDocumentText Document
detectDocumentText_document :: (Document -> f Document)
-> DetectDocumentText -> f DetectDocumentText
detectDocumentText_document = (DetectDocumentText -> Document)
-> (DetectDocumentText -> Document -> DetectDocumentText)
-> Lens DetectDocumentText DetectDocumentText Document Document
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DetectDocumentText' {Document
document :: Document
$sel:document:DetectDocumentText' :: DetectDocumentText -> Document
document} -> Document
document) (\s :: DetectDocumentText
s@DetectDocumentText' {} Document
a -> DetectDocumentText
s {$sel:document:DetectDocumentText' :: Document
document = Document
a} :: DetectDocumentText)
instance Core.AWSRequest DetectDocumentText where
type
AWSResponse DetectDocumentText =
DetectDocumentTextResponse
request :: DetectDocumentText -> Request DetectDocumentText
request = Service -> DetectDocumentText -> Request DetectDocumentText
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
response :: Logger
-> Service
-> Proxy DetectDocumentText
-> ClientResponse ClientBody
-> m (Either
Error (ClientResponse (AWSResponse DetectDocumentText)))
response =
(Int
-> ResponseHeaders
-> Object
-> Either String (AWSResponse DetectDocumentText))
-> Logger
-> Service
-> Proxy DetectDocumentText
-> ClientResponse ClientBody
-> m (Either
Error (ClientResponse (AWSResponse DetectDocumentText)))
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 DocumentMetadata
-> Maybe [Block] -> Maybe Text -> Int -> DetectDocumentTextResponse
DetectDocumentTextResponse'
(Maybe DocumentMetadata
-> Maybe [Block]
-> Maybe Text
-> Int
-> DetectDocumentTextResponse)
-> Either String (Maybe DocumentMetadata)
-> Either
String
(Maybe [Block] -> Maybe Text -> Int -> DetectDocumentTextResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Either String (Maybe DocumentMetadata)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"DocumentMetadata")
Either
String
(Maybe [Block] -> Maybe Text -> Int -> DetectDocumentTextResponse)
-> Either String (Maybe [Block])
-> Either String (Maybe Text -> Int -> DetectDocumentTextResponse)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Either String (Maybe (Maybe [Block]))
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"Blocks" Either String (Maybe (Maybe [Block]))
-> Maybe [Block] -> Either String (Maybe [Block])
forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ Maybe [Block]
forall a. Monoid a => a
Prelude.mempty)
Either String (Maybe Text -> Int -> DetectDocumentTextResponse)
-> Either String (Maybe Text)
-> Either String (Int -> DetectDocumentTextResponse)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Either String (Maybe Text)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"DetectDocumentTextModelVersion")
Either String (Int -> DetectDocumentTextResponse)
-> Either String Int -> Either String DetectDocumentTextResponse
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 DetectDocumentText
instance Prelude.NFData DetectDocumentText
instance Core.ToHeaders DetectDocumentText where
toHeaders :: DetectDocumentText -> ResponseHeaders
toHeaders =
ResponseHeaders -> DetectDocumentText -> 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
"Textract.DetectDocumentText" ::
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 DetectDocumentText where
toJSON :: DetectDocumentText -> Value
toJSON DetectDocumentText' {Document
document :: Document
$sel:document:DetectDocumentText' :: DetectDocumentText -> Document
..} =
[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
"Document" Text -> Document -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Document
document)]
)
instance Core.ToPath DetectDocumentText where
toPath :: DetectDocumentText -> ByteString
toPath = ByteString -> DetectDocumentText -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/"
instance Core.ToQuery DetectDocumentText where
toQuery :: DetectDocumentText -> QueryString
toQuery = QueryString -> DetectDocumentText -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
forall a. Monoid a => a
Prelude.mempty
data DetectDocumentTextResponse = DetectDocumentTextResponse'
{
DetectDocumentTextResponse -> Maybe DocumentMetadata
documentMetadata :: Prelude.Maybe DocumentMetadata,
DetectDocumentTextResponse -> Maybe [Block]
blocks :: Prelude.Maybe [Block],
DetectDocumentTextResponse -> Maybe Text
detectDocumentTextModelVersion :: Prelude.Maybe Prelude.Text,
DetectDocumentTextResponse -> Int
httpStatus :: Prelude.Int
}
deriving (DetectDocumentTextResponse -> DetectDocumentTextResponse -> Bool
(DetectDocumentTextResponse -> DetectDocumentTextResponse -> Bool)
-> (DetectDocumentTextResponse
-> DetectDocumentTextResponse -> Bool)
-> Eq DetectDocumentTextResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DetectDocumentTextResponse -> DetectDocumentTextResponse -> Bool
$c/= :: DetectDocumentTextResponse -> DetectDocumentTextResponse -> Bool
== :: DetectDocumentTextResponse -> DetectDocumentTextResponse -> Bool
$c== :: DetectDocumentTextResponse -> DetectDocumentTextResponse -> Bool
Prelude.Eq, ReadPrec [DetectDocumentTextResponse]
ReadPrec DetectDocumentTextResponse
Int -> ReadS DetectDocumentTextResponse
ReadS [DetectDocumentTextResponse]
(Int -> ReadS DetectDocumentTextResponse)
-> ReadS [DetectDocumentTextResponse]
-> ReadPrec DetectDocumentTextResponse
-> ReadPrec [DetectDocumentTextResponse]
-> Read DetectDocumentTextResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DetectDocumentTextResponse]
$creadListPrec :: ReadPrec [DetectDocumentTextResponse]
readPrec :: ReadPrec DetectDocumentTextResponse
$creadPrec :: ReadPrec DetectDocumentTextResponse
readList :: ReadS [DetectDocumentTextResponse]
$creadList :: ReadS [DetectDocumentTextResponse]
readsPrec :: Int -> ReadS DetectDocumentTextResponse
$creadsPrec :: Int -> ReadS DetectDocumentTextResponse
Prelude.Read, Int -> DetectDocumentTextResponse -> ShowS
[DetectDocumentTextResponse] -> ShowS
DetectDocumentTextResponse -> String
(Int -> DetectDocumentTextResponse -> ShowS)
-> (DetectDocumentTextResponse -> String)
-> ([DetectDocumentTextResponse] -> ShowS)
-> Show DetectDocumentTextResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DetectDocumentTextResponse] -> ShowS
$cshowList :: [DetectDocumentTextResponse] -> ShowS
show :: DetectDocumentTextResponse -> String
$cshow :: DetectDocumentTextResponse -> String
showsPrec :: Int -> DetectDocumentTextResponse -> ShowS
$cshowsPrec :: Int -> DetectDocumentTextResponse -> ShowS
Prelude.Show, (forall x.
DetectDocumentTextResponse -> Rep DetectDocumentTextResponse x)
-> (forall x.
Rep DetectDocumentTextResponse x -> DetectDocumentTextResponse)
-> Generic DetectDocumentTextResponse
forall x.
Rep DetectDocumentTextResponse x -> DetectDocumentTextResponse
forall x.
DetectDocumentTextResponse -> Rep DetectDocumentTextResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep DetectDocumentTextResponse x -> DetectDocumentTextResponse
$cfrom :: forall x.
DetectDocumentTextResponse -> Rep DetectDocumentTextResponse x
Prelude.Generic)
newDetectDocumentTextResponse ::
Prelude.Int ->
DetectDocumentTextResponse
newDetectDocumentTextResponse :: Int -> DetectDocumentTextResponse
newDetectDocumentTextResponse Int
pHttpStatus_ =
DetectDocumentTextResponse' :: Maybe DocumentMetadata
-> Maybe [Block] -> Maybe Text -> Int -> DetectDocumentTextResponse
DetectDocumentTextResponse'
{ $sel:documentMetadata:DetectDocumentTextResponse' :: Maybe DocumentMetadata
documentMetadata =
Maybe DocumentMetadata
forall a. Maybe a
Prelude.Nothing,
$sel:blocks:DetectDocumentTextResponse' :: Maybe [Block]
blocks = Maybe [Block]
forall a. Maybe a
Prelude.Nothing,
$sel:detectDocumentTextModelVersion:DetectDocumentTextResponse' :: Maybe Text
detectDocumentTextModelVersion =
Maybe Text
forall a. Maybe a
Prelude.Nothing,
$sel:httpStatus:DetectDocumentTextResponse' :: Int
httpStatus = Int
pHttpStatus_
}
detectDocumentTextResponse_documentMetadata :: Lens.Lens' DetectDocumentTextResponse (Prelude.Maybe DocumentMetadata)
detectDocumentTextResponse_documentMetadata :: (Maybe DocumentMetadata -> f (Maybe DocumentMetadata))
-> DetectDocumentTextResponse -> f DetectDocumentTextResponse
detectDocumentTextResponse_documentMetadata = (DetectDocumentTextResponse -> Maybe DocumentMetadata)
-> (DetectDocumentTextResponse
-> Maybe DocumentMetadata -> DetectDocumentTextResponse)
-> Lens
DetectDocumentTextResponse
DetectDocumentTextResponse
(Maybe DocumentMetadata)
(Maybe DocumentMetadata)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DetectDocumentTextResponse' {Maybe DocumentMetadata
documentMetadata :: Maybe DocumentMetadata
$sel:documentMetadata:DetectDocumentTextResponse' :: DetectDocumentTextResponse -> Maybe DocumentMetadata
documentMetadata} -> Maybe DocumentMetadata
documentMetadata) (\s :: DetectDocumentTextResponse
s@DetectDocumentTextResponse' {} Maybe DocumentMetadata
a -> DetectDocumentTextResponse
s {$sel:documentMetadata:DetectDocumentTextResponse' :: Maybe DocumentMetadata
documentMetadata = Maybe DocumentMetadata
a} :: DetectDocumentTextResponse)
detectDocumentTextResponse_blocks :: Lens.Lens' DetectDocumentTextResponse (Prelude.Maybe [Block])
detectDocumentTextResponse_blocks :: (Maybe [Block] -> f (Maybe [Block]))
-> DetectDocumentTextResponse -> f DetectDocumentTextResponse
detectDocumentTextResponse_blocks = (DetectDocumentTextResponse -> Maybe [Block])
-> (DetectDocumentTextResponse
-> Maybe [Block] -> DetectDocumentTextResponse)
-> Lens
DetectDocumentTextResponse
DetectDocumentTextResponse
(Maybe [Block])
(Maybe [Block])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DetectDocumentTextResponse' {Maybe [Block]
blocks :: Maybe [Block]
$sel:blocks:DetectDocumentTextResponse' :: DetectDocumentTextResponse -> Maybe [Block]
blocks} -> Maybe [Block]
blocks) (\s :: DetectDocumentTextResponse
s@DetectDocumentTextResponse' {} Maybe [Block]
a -> DetectDocumentTextResponse
s {$sel:blocks:DetectDocumentTextResponse' :: Maybe [Block]
blocks = Maybe [Block]
a} :: DetectDocumentTextResponse) ((Maybe [Block] -> f (Maybe [Block]))
-> DetectDocumentTextResponse -> f DetectDocumentTextResponse)
-> ((Maybe [Block] -> f (Maybe [Block]))
-> Maybe [Block] -> f (Maybe [Block]))
-> (Maybe [Block] -> f (Maybe [Block]))
-> DetectDocumentTextResponse
-> f DetectDocumentTextResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Block] [Block] [Block] [Block]
-> Iso
(Maybe [Block]) (Maybe [Block]) (Maybe [Block]) (Maybe [Block])
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 [Block] [Block] [Block] [Block]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced
detectDocumentTextResponse_detectDocumentTextModelVersion :: Lens.Lens' DetectDocumentTextResponse (Prelude.Maybe Prelude.Text)
detectDocumentTextResponse_detectDocumentTextModelVersion :: (Maybe Text -> f (Maybe Text))
-> DetectDocumentTextResponse -> f DetectDocumentTextResponse
detectDocumentTextResponse_detectDocumentTextModelVersion = (DetectDocumentTextResponse -> Maybe Text)
-> (DetectDocumentTextResponse
-> Maybe Text -> DetectDocumentTextResponse)
-> Lens
DetectDocumentTextResponse
DetectDocumentTextResponse
(Maybe Text)
(Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DetectDocumentTextResponse' {Maybe Text
detectDocumentTextModelVersion :: Maybe Text
$sel:detectDocumentTextModelVersion:DetectDocumentTextResponse' :: DetectDocumentTextResponse -> Maybe Text
detectDocumentTextModelVersion} -> Maybe Text
detectDocumentTextModelVersion) (\s :: DetectDocumentTextResponse
s@DetectDocumentTextResponse' {} Maybe Text
a -> DetectDocumentTextResponse
s {$sel:detectDocumentTextModelVersion:DetectDocumentTextResponse' :: Maybe Text
detectDocumentTextModelVersion = Maybe Text
a} :: DetectDocumentTextResponse)
detectDocumentTextResponse_httpStatus :: Lens.Lens' DetectDocumentTextResponse Prelude.Int
detectDocumentTextResponse_httpStatus :: (Int -> f Int)
-> DetectDocumentTextResponse -> f DetectDocumentTextResponse
detectDocumentTextResponse_httpStatus = (DetectDocumentTextResponse -> Int)
-> (DetectDocumentTextResponse
-> Int -> DetectDocumentTextResponse)
-> Lens
DetectDocumentTextResponse DetectDocumentTextResponse Int Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DetectDocumentTextResponse' {Int
httpStatus :: Int
$sel:httpStatus:DetectDocumentTextResponse' :: DetectDocumentTextResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: DetectDocumentTextResponse
s@DetectDocumentTextResponse' {} Int
a -> DetectDocumentTextResponse
s {$sel:httpStatus:DetectDocumentTextResponse' :: Int
httpStatus = Int
a} :: DetectDocumentTextResponse)
instance Prelude.NFData DetectDocumentTextResponse