{-# 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.Rekognition.DetectText
(
DetectText (..),
newDetectText,
detectText_filters,
detectText_image,
DetectTextResponse (..),
newDetectTextResponse,
detectTextResponse_textDetections,
detectTextResponse_textModelVersion,
detectTextResponse_httpStatus,
)
where
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import Amazonka.Rekognition.Types
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response
data DetectText = DetectText'
{
DetectText -> Maybe DetectTextFilters
filters :: Prelude.Maybe DetectTextFilters,
DetectText -> Image
image :: Image
}
deriving (DetectText -> DetectText -> Bool
(DetectText -> DetectText -> Bool)
-> (DetectText -> DetectText -> Bool) -> Eq DetectText
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DetectText -> DetectText -> Bool
$c/= :: DetectText -> DetectText -> Bool
== :: DetectText -> DetectText -> Bool
$c== :: DetectText -> DetectText -> Bool
Prelude.Eq, ReadPrec [DetectText]
ReadPrec DetectText
Int -> ReadS DetectText
ReadS [DetectText]
(Int -> ReadS DetectText)
-> ReadS [DetectText]
-> ReadPrec DetectText
-> ReadPrec [DetectText]
-> Read DetectText
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DetectText]
$creadListPrec :: ReadPrec [DetectText]
readPrec :: ReadPrec DetectText
$creadPrec :: ReadPrec DetectText
readList :: ReadS [DetectText]
$creadList :: ReadS [DetectText]
readsPrec :: Int -> ReadS DetectText
$creadsPrec :: Int -> ReadS DetectText
Prelude.Read, Int -> DetectText -> ShowS
[DetectText] -> ShowS
DetectText -> String
(Int -> DetectText -> ShowS)
-> (DetectText -> String)
-> ([DetectText] -> ShowS)
-> Show DetectText
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DetectText] -> ShowS
$cshowList :: [DetectText] -> ShowS
show :: DetectText -> String
$cshow :: DetectText -> String
showsPrec :: Int -> DetectText -> ShowS
$cshowsPrec :: Int -> DetectText -> ShowS
Prelude.Show, (forall x. DetectText -> Rep DetectText x)
-> (forall x. Rep DetectText x -> DetectText) -> Generic DetectText
forall x. Rep DetectText x -> DetectText
forall x. DetectText -> Rep DetectText x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DetectText x -> DetectText
$cfrom :: forall x. DetectText -> Rep DetectText x
Prelude.Generic)
newDetectText ::
Image ->
DetectText
newDetectText :: Image -> DetectText
newDetectText Image
pImage_ =
DetectText' :: Maybe DetectTextFilters -> Image -> DetectText
DetectText'
{ $sel:filters:DetectText' :: Maybe DetectTextFilters
filters = Maybe DetectTextFilters
forall a. Maybe a
Prelude.Nothing,
$sel:image:DetectText' :: Image
image = Image
pImage_
}
detectText_filters :: Lens.Lens' DetectText (Prelude.Maybe DetectTextFilters)
detectText_filters :: (Maybe DetectTextFilters -> f (Maybe DetectTextFilters))
-> DetectText -> f DetectText
detectText_filters = (DetectText -> Maybe DetectTextFilters)
-> (DetectText -> Maybe DetectTextFilters -> DetectText)
-> Lens
DetectText
DetectText
(Maybe DetectTextFilters)
(Maybe DetectTextFilters)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DetectText' {Maybe DetectTextFilters
filters :: Maybe DetectTextFilters
$sel:filters:DetectText' :: DetectText -> Maybe DetectTextFilters
filters} -> Maybe DetectTextFilters
filters) (\s :: DetectText
s@DetectText' {} Maybe DetectTextFilters
a -> DetectText
s {$sel:filters:DetectText' :: Maybe DetectTextFilters
filters = Maybe DetectTextFilters
a} :: DetectText)
detectText_image :: Lens.Lens' DetectText Image
detectText_image :: (Image -> f Image) -> DetectText -> f DetectText
detectText_image = (DetectText -> Image)
-> (DetectText -> Image -> DetectText)
-> Lens DetectText DetectText Image Image
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DetectText' {Image
image :: Image
$sel:image:DetectText' :: DetectText -> Image
image} -> Image
image) (\s :: DetectText
s@DetectText' {} Image
a -> DetectText
s {$sel:image:DetectText' :: Image
image = Image
a} :: DetectText)
instance Core.AWSRequest DetectText where
type AWSResponse DetectText = DetectTextResponse
request :: DetectText -> Request DetectText
request = Service -> DetectText -> Request DetectText
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
response :: Logger
-> Service
-> Proxy DetectText
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse DetectText)))
response =
(Int
-> ResponseHeaders
-> Object
-> Either String (AWSResponse DetectText))
-> Logger
-> Service
-> Proxy DetectText
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse DetectText)))
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 [TextDetection] -> Maybe Text -> Int -> DetectTextResponse
DetectTextResponse'
(Maybe [TextDetection] -> Maybe Text -> Int -> DetectTextResponse)
-> Either String (Maybe [TextDetection])
-> Either String (Maybe Text -> Int -> DetectTextResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Either String (Maybe (Maybe [TextDetection]))
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"TextDetections" Either String (Maybe (Maybe [TextDetection]))
-> Maybe [TextDetection] -> Either String (Maybe [TextDetection])
forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ Maybe [TextDetection]
forall a. Monoid a => a
Prelude.mempty)
Either String (Maybe Text -> Int -> DetectTextResponse)
-> Either String (Maybe Text)
-> Either String (Int -> DetectTextResponse)
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
"TextModelVersion")
Either String (Int -> DetectTextResponse)
-> Either String Int -> Either String DetectTextResponse
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 DetectText
instance Prelude.NFData DetectText
instance Core.ToHeaders DetectText where
toHeaders :: DetectText -> ResponseHeaders
toHeaders =
ResponseHeaders -> DetectText -> 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
"RekognitionService.DetectText" ::
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 DetectText where
toJSON :: DetectText -> Value
toJSON DetectText' {Maybe DetectTextFilters
Image
image :: Image
filters :: Maybe DetectTextFilters
$sel:image:DetectText' :: DetectText -> Image
$sel:filters:DetectText' :: DetectText -> Maybe DetectTextFilters
..} =
[Pair] -> Value
Core.object
( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
[ (Text
"Filters" Text -> DetectTextFilters -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (DetectTextFilters -> Pair)
-> Maybe DetectTextFilters -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe DetectTextFilters
filters,
Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"Image" Text -> Image -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Image
image)
]
)
instance Core.ToPath DetectText where
toPath :: DetectText -> ByteString
toPath = ByteString -> DetectText -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/"
instance Core.ToQuery DetectText where
toQuery :: DetectText -> QueryString
toQuery = QueryString -> DetectText -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
forall a. Monoid a => a
Prelude.mempty
data DetectTextResponse = DetectTextResponse'
{
DetectTextResponse -> Maybe [TextDetection]
textDetections :: Prelude.Maybe [TextDetection],
DetectTextResponse -> Maybe Text
textModelVersion :: Prelude.Maybe Prelude.Text,
DetectTextResponse -> Int
httpStatus :: Prelude.Int
}
deriving (DetectTextResponse -> DetectTextResponse -> Bool
(DetectTextResponse -> DetectTextResponse -> Bool)
-> (DetectTextResponse -> DetectTextResponse -> Bool)
-> Eq DetectTextResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DetectTextResponse -> DetectTextResponse -> Bool
$c/= :: DetectTextResponse -> DetectTextResponse -> Bool
== :: DetectTextResponse -> DetectTextResponse -> Bool
$c== :: DetectTextResponse -> DetectTextResponse -> Bool
Prelude.Eq, ReadPrec [DetectTextResponse]
ReadPrec DetectTextResponse
Int -> ReadS DetectTextResponse
ReadS [DetectTextResponse]
(Int -> ReadS DetectTextResponse)
-> ReadS [DetectTextResponse]
-> ReadPrec DetectTextResponse
-> ReadPrec [DetectTextResponse]
-> Read DetectTextResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DetectTextResponse]
$creadListPrec :: ReadPrec [DetectTextResponse]
readPrec :: ReadPrec DetectTextResponse
$creadPrec :: ReadPrec DetectTextResponse
readList :: ReadS [DetectTextResponse]
$creadList :: ReadS [DetectTextResponse]
readsPrec :: Int -> ReadS DetectTextResponse
$creadsPrec :: Int -> ReadS DetectTextResponse
Prelude.Read, Int -> DetectTextResponse -> ShowS
[DetectTextResponse] -> ShowS
DetectTextResponse -> String
(Int -> DetectTextResponse -> ShowS)
-> (DetectTextResponse -> String)
-> ([DetectTextResponse] -> ShowS)
-> Show DetectTextResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DetectTextResponse] -> ShowS
$cshowList :: [DetectTextResponse] -> ShowS
show :: DetectTextResponse -> String
$cshow :: DetectTextResponse -> String
showsPrec :: Int -> DetectTextResponse -> ShowS
$cshowsPrec :: Int -> DetectTextResponse -> ShowS
Prelude.Show, (forall x. DetectTextResponse -> Rep DetectTextResponse x)
-> (forall x. Rep DetectTextResponse x -> DetectTextResponse)
-> Generic DetectTextResponse
forall x. Rep DetectTextResponse x -> DetectTextResponse
forall x. DetectTextResponse -> Rep DetectTextResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DetectTextResponse x -> DetectTextResponse
$cfrom :: forall x. DetectTextResponse -> Rep DetectTextResponse x
Prelude.Generic)
newDetectTextResponse ::
Prelude.Int ->
DetectTextResponse
newDetectTextResponse :: Int -> DetectTextResponse
newDetectTextResponse Int
pHttpStatus_ =
DetectTextResponse' :: Maybe [TextDetection] -> Maybe Text -> Int -> DetectTextResponse
DetectTextResponse'
{ $sel:textDetections:DetectTextResponse' :: Maybe [TextDetection]
textDetections =
Maybe [TextDetection]
forall a. Maybe a
Prelude.Nothing,
$sel:textModelVersion:DetectTextResponse' :: Maybe Text
textModelVersion = Maybe Text
forall a. Maybe a
Prelude.Nothing,
$sel:httpStatus:DetectTextResponse' :: Int
httpStatus = Int
pHttpStatus_
}
detectTextResponse_textDetections :: Lens.Lens' DetectTextResponse (Prelude.Maybe [TextDetection])
detectTextResponse_textDetections :: (Maybe [TextDetection] -> f (Maybe [TextDetection]))
-> DetectTextResponse -> f DetectTextResponse
detectTextResponse_textDetections = (DetectTextResponse -> Maybe [TextDetection])
-> (DetectTextResponse
-> Maybe [TextDetection] -> DetectTextResponse)
-> Lens
DetectTextResponse
DetectTextResponse
(Maybe [TextDetection])
(Maybe [TextDetection])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DetectTextResponse' {Maybe [TextDetection]
textDetections :: Maybe [TextDetection]
$sel:textDetections:DetectTextResponse' :: DetectTextResponse -> Maybe [TextDetection]
textDetections} -> Maybe [TextDetection]
textDetections) (\s :: DetectTextResponse
s@DetectTextResponse' {} Maybe [TextDetection]
a -> DetectTextResponse
s {$sel:textDetections:DetectTextResponse' :: Maybe [TextDetection]
textDetections = Maybe [TextDetection]
a} :: DetectTextResponse) ((Maybe [TextDetection] -> f (Maybe [TextDetection]))
-> DetectTextResponse -> f DetectTextResponse)
-> ((Maybe [TextDetection] -> f (Maybe [TextDetection]))
-> Maybe [TextDetection] -> f (Maybe [TextDetection]))
-> (Maybe [TextDetection] -> f (Maybe [TextDetection]))
-> DetectTextResponse
-> f DetectTextResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
[TextDetection] [TextDetection] [TextDetection] [TextDetection]
-> Iso
(Maybe [TextDetection])
(Maybe [TextDetection])
(Maybe [TextDetection])
(Maybe [TextDetection])
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
[TextDetection] [TextDetection] [TextDetection] [TextDetection]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced
detectTextResponse_textModelVersion :: Lens.Lens' DetectTextResponse (Prelude.Maybe Prelude.Text)
detectTextResponse_textModelVersion :: (Maybe Text -> f (Maybe Text))
-> DetectTextResponse -> f DetectTextResponse
detectTextResponse_textModelVersion = (DetectTextResponse -> Maybe Text)
-> (DetectTextResponse -> Maybe Text -> DetectTextResponse)
-> Lens
DetectTextResponse DetectTextResponse (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DetectTextResponse' {Maybe Text
textModelVersion :: Maybe Text
$sel:textModelVersion:DetectTextResponse' :: DetectTextResponse -> Maybe Text
textModelVersion} -> Maybe Text
textModelVersion) (\s :: DetectTextResponse
s@DetectTextResponse' {} Maybe Text
a -> DetectTextResponse
s {$sel:textModelVersion:DetectTextResponse' :: Maybe Text
textModelVersion = Maybe Text
a} :: DetectTextResponse)
detectTextResponse_httpStatus :: Lens.Lens' DetectTextResponse Prelude.Int
detectTextResponse_httpStatus :: (Int -> f Int) -> DetectTextResponse -> f DetectTextResponse
detectTextResponse_httpStatus = (DetectTextResponse -> Int)
-> (DetectTextResponse -> Int -> DetectTextResponse)
-> Lens DetectTextResponse DetectTextResponse Int Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DetectTextResponse' {Int
httpStatus :: Int
$sel:httpStatus:DetectTextResponse' :: DetectTextResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: DetectTextResponse
s@DetectTextResponse' {} Int
a -> DetectTextResponse
s {$sel:httpStatus:DetectTextResponse' :: Int
httpStatus = Int
a} :: DetectTextResponse)
instance Prelude.NFData DetectTextResponse