{-# 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_blocks,
detectDocumentTextResponse_detectDocumentTextModelVersion,
detectDocumentTextResponse_documentMetadata,
detectDocumentTextResponse_httpStatus,
)
where
import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
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
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]
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
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. 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' {$sel:document:DetectDocumentText' :: Document
document = Document
pDocument_}
detectDocumentText_document :: Lens.Lens' DetectDocumentText Document
detectDocumentText_document :: Lens' DetectDocumentText Document
detectDocumentText_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 :: (Service -> Service)
-> DetectDocumentText -> Request DetectDocumentText
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 DetectDocumentText
-> ClientResponse ClientBody
-> m (Either
Error (ClientResponse (AWSResponse DetectDocumentText)))
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 [Block]
-> Maybe Text
-> Maybe DocumentMetadata
-> Int
-> DetectDocumentTextResponse
DetectDocumentTextResponse'
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
"Blocks" forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ forall a. Monoid a => a
Prelude.mempty)
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
"DetectDocumentTextModelVersion")
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
"DocumentMetadata")
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 DetectDocumentText where
hashWithSalt :: Int -> DetectDocumentText -> Int
hashWithSalt Int
_salt DetectDocumentText' {Document
document :: Document
$sel:document:DetectDocumentText' :: DetectDocumentText -> Document
..} =
Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Document
document
instance Prelude.NFData DetectDocumentText where
rnf :: DetectDocumentText -> ()
rnf DetectDocumentText' {Document
document :: Document
$sel:document:DetectDocumentText' :: DetectDocumentText -> Document
..} = forall a. NFData a => a -> ()
Prelude.rnf Document
document
instance Data.ToHeaders DetectDocumentText where
toHeaders :: DetectDocumentText -> 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
"Textract.DetectDocumentText" ::
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 DetectDocumentText where
toJSON :: DetectDocumentText -> Value
toJSON DetectDocumentText' {Document
document :: Document
$sel:document:DetectDocumentText' :: DetectDocumentText -> Document
..} =
[Pair] -> Value
Data.object
( forall a. [Maybe a] -> [a]
Prelude.catMaybes
[forall a. a -> Maybe a
Prelude.Just (Key
"Document" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Document
document)]
)
instance Data.ToPath DetectDocumentText where
toPath :: DetectDocumentText -> ByteString
toPath = forall a b. a -> b -> a
Prelude.const ByteString
"/"
instance Data.ToQuery DetectDocumentText where
toQuery :: DetectDocumentText -> QueryString
toQuery = forall a b. a -> b -> a
Prelude.const forall a. Monoid a => a
Prelude.mempty
data DetectDocumentTextResponse = DetectDocumentTextResponse'
{
DetectDocumentTextResponse -> Maybe [Block]
blocks :: Prelude.Maybe [Block],
DetectDocumentTextResponse -> Maybe Text
detectDocumentTextModelVersion :: Prelude.Maybe Prelude.Text,
DetectDocumentTextResponse -> Maybe DocumentMetadata
documentMetadata :: Prelude.Maybe DocumentMetadata,
DetectDocumentTextResponse -> Int
httpStatus :: Prelude.Int
}
deriving (DetectDocumentTextResponse -> DetectDocumentTextResponse -> Bool
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]
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
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.
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'
{ $sel:blocks:DetectDocumentTextResponse' :: Maybe [Block]
blocks =
forall a. Maybe a
Prelude.Nothing,
$sel:detectDocumentTextModelVersion:DetectDocumentTextResponse' :: Maybe Text
detectDocumentTextModelVersion =
forall a. Maybe a
Prelude.Nothing,
$sel:documentMetadata:DetectDocumentTextResponse' :: Maybe DocumentMetadata
documentMetadata = forall a. Maybe a
Prelude.Nothing,
$sel:httpStatus:DetectDocumentTextResponse' :: Int
httpStatus = Int
pHttpStatus_
}
detectDocumentTextResponse_blocks :: Lens.Lens' DetectDocumentTextResponse (Prelude.Maybe [Block])
detectDocumentTextResponse_blocks :: Lens' DetectDocumentTextResponse (Maybe [Block])
detectDocumentTextResponse_blocks = 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) 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
detectDocumentTextResponse_detectDocumentTextModelVersion :: Lens.Lens' DetectDocumentTextResponse (Prelude.Maybe Prelude.Text)
detectDocumentTextResponse_detectDocumentTextModelVersion :: Lens' DetectDocumentTextResponse (Maybe Text)
detectDocumentTextResponse_detectDocumentTextModelVersion = 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_documentMetadata :: Lens.Lens' DetectDocumentTextResponse (Prelude.Maybe DocumentMetadata)
detectDocumentTextResponse_documentMetadata :: Lens' DetectDocumentTextResponse (Maybe DocumentMetadata)
detectDocumentTextResponse_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_httpStatus :: Lens.Lens' DetectDocumentTextResponse Prelude.Int
detectDocumentTextResponse_httpStatus :: Lens' DetectDocumentTextResponse Int
detectDocumentTextResponse_httpStatus = 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 where
rnf :: DetectDocumentTextResponse -> ()
rnf DetectDocumentTextResponse' {Int
Maybe [Block]
Maybe Text
Maybe DocumentMetadata
httpStatus :: Int
documentMetadata :: Maybe DocumentMetadata
detectDocumentTextModelVersion :: Maybe Text
blocks :: Maybe [Block]
$sel:httpStatus:DetectDocumentTextResponse' :: DetectDocumentTextResponse -> Int
$sel:documentMetadata:DetectDocumentTextResponse' :: DetectDocumentTextResponse -> Maybe DocumentMetadata
$sel:detectDocumentTextModelVersion:DetectDocumentTextResponse' :: DetectDocumentTextResponse -> Maybe Text
$sel:blocks:DetectDocumentTextResponse' :: DetectDocumentTextResponse -> Maybe [Block]
..} =
forall a. NFData a => a -> ()
Prelude.rnf Maybe [Block]
blocks
seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
detectDocumentTextModelVersion
seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe DocumentMetadata
documentMetadata
seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus