{-# 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.DetectLabels
(
DetectLabels (..),
newDetectLabels,
detectLabels_minConfidence,
detectLabels_maxLabels,
detectLabels_image,
DetectLabelsResponse (..),
newDetectLabelsResponse,
detectLabelsResponse_labels,
detectLabelsResponse_orientationCorrection,
detectLabelsResponse_labelModelVersion,
detectLabelsResponse_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 DetectLabels = DetectLabels'
{
DetectLabels -> Maybe Double
minConfidence :: Prelude.Maybe Prelude.Double,
DetectLabels -> Maybe Natural
maxLabels :: Prelude.Maybe Prelude.Natural,
DetectLabels -> Image
image :: Image
}
deriving (DetectLabels -> DetectLabels -> Bool
(DetectLabels -> DetectLabels -> Bool)
-> (DetectLabels -> DetectLabels -> Bool) -> Eq DetectLabels
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DetectLabels -> DetectLabels -> Bool
$c/= :: DetectLabels -> DetectLabels -> Bool
== :: DetectLabels -> DetectLabels -> Bool
$c== :: DetectLabels -> DetectLabels -> Bool
Prelude.Eq, ReadPrec [DetectLabels]
ReadPrec DetectLabels
Int -> ReadS DetectLabels
ReadS [DetectLabels]
(Int -> ReadS DetectLabels)
-> ReadS [DetectLabels]
-> ReadPrec DetectLabels
-> ReadPrec [DetectLabels]
-> Read DetectLabels
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DetectLabels]
$creadListPrec :: ReadPrec [DetectLabels]
readPrec :: ReadPrec DetectLabels
$creadPrec :: ReadPrec DetectLabels
readList :: ReadS [DetectLabels]
$creadList :: ReadS [DetectLabels]
readsPrec :: Int -> ReadS DetectLabels
$creadsPrec :: Int -> ReadS DetectLabels
Prelude.Read, Int -> DetectLabels -> ShowS
[DetectLabels] -> ShowS
DetectLabels -> String
(Int -> DetectLabels -> ShowS)
-> (DetectLabels -> String)
-> ([DetectLabels] -> ShowS)
-> Show DetectLabels
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DetectLabels] -> ShowS
$cshowList :: [DetectLabels] -> ShowS
show :: DetectLabels -> String
$cshow :: DetectLabels -> String
showsPrec :: Int -> DetectLabels -> ShowS
$cshowsPrec :: Int -> DetectLabels -> ShowS
Prelude.Show, (forall x. DetectLabels -> Rep DetectLabels x)
-> (forall x. Rep DetectLabels x -> DetectLabels)
-> Generic DetectLabels
forall x. Rep DetectLabels x -> DetectLabels
forall x. DetectLabels -> Rep DetectLabels x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DetectLabels x -> DetectLabels
$cfrom :: forall x. DetectLabels -> Rep DetectLabels x
Prelude.Generic)
newDetectLabels ::
Image ->
DetectLabels
newDetectLabels :: Image -> DetectLabels
newDetectLabels Image
pImage_ =
DetectLabels' :: Maybe Double -> Maybe Natural -> Image -> DetectLabels
DetectLabels'
{ $sel:minConfidence:DetectLabels' :: Maybe Double
minConfidence = Maybe Double
forall a. Maybe a
Prelude.Nothing,
$sel:maxLabels:DetectLabels' :: Maybe Natural
maxLabels = Maybe Natural
forall a. Maybe a
Prelude.Nothing,
$sel:image:DetectLabels' :: Image
image = Image
pImage_
}
detectLabels_minConfidence :: Lens.Lens' DetectLabels (Prelude.Maybe Prelude.Double)
detectLabels_minConfidence :: (Maybe Double -> f (Maybe Double))
-> DetectLabels -> f DetectLabels
detectLabels_minConfidence = (DetectLabels -> Maybe Double)
-> (DetectLabels -> Maybe Double -> DetectLabels)
-> Lens DetectLabels DetectLabels (Maybe Double) (Maybe Double)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DetectLabels' {Maybe Double
minConfidence :: Maybe Double
$sel:minConfidence:DetectLabels' :: DetectLabels -> Maybe Double
minConfidence} -> Maybe Double
minConfidence) (\s :: DetectLabels
s@DetectLabels' {} Maybe Double
a -> DetectLabels
s {$sel:minConfidence:DetectLabels' :: Maybe Double
minConfidence = Maybe Double
a} :: DetectLabels)
detectLabels_maxLabels :: Lens.Lens' DetectLabels (Prelude.Maybe Prelude.Natural)
detectLabels_maxLabels :: (Maybe Natural -> f (Maybe Natural))
-> DetectLabels -> f DetectLabels
detectLabels_maxLabels = (DetectLabels -> Maybe Natural)
-> (DetectLabels -> Maybe Natural -> DetectLabels)
-> Lens DetectLabels DetectLabels (Maybe Natural) (Maybe Natural)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DetectLabels' {Maybe Natural
maxLabels :: Maybe Natural
$sel:maxLabels:DetectLabels' :: DetectLabels -> Maybe Natural
maxLabels} -> Maybe Natural
maxLabels) (\s :: DetectLabels
s@DetectLabels' {} Maybe Natural
a -> DetectLabels
s {$sel:maxLabels:DetectLabels' :: Maybe Natural
maxLabels = Maybe Natural
a} :: DetectLabels)
detectLabels_image :: Lens.Lens' DetectLabels Image
detectLabels_image :: (Image -> f Image) -> DetectLabels -> f DetectLabels
detectLabels_image = (DetectLabels -> Image)
-> (DetectLabels -> Image -> DetectLabels)
-> Lens DetectLabels DetectLabels Image Image
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DetectLabels' {Image
image :: Image
$sel:image:DetectLabels' :: DetectLabels -> Image
image} -> Image
image) (\s :: DetectLabels
s@DetectLabels' {} Image
a -> DetectLabels
s {$sel:image:DetectLabels' :: Image
image = Image
a} :: DetectLabels)
instance Core.AWSRequest DetectLabels where
type AWSResponse DetectLabels = DetectLabelsResponse
request :: DetectLabels -> Request DetectLabels
request = Service -> DetectLabels -> Request DetectLabels
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
response :: Logger
-> Service
-> Proxy DetectLabels
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse DetectLabels)))
response =
(Int
-> ResponseHeaders
-> Object
-> Either String (AWSResponse DetectLabels))
-> Logger
-> Service
-> Proxy DetectLabels
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse DetectLabels)))
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 [Label]
-> Maybe OrientationCorrection
-> Maybe Text
-> Int
-> DetectLabelsResponse
DetectLabelsResponse'
(Maybe [Label]
-> Maybe OrientationCorrection
-> Maybe Text
-> Int
-> DetectLabelsResponse)
-> Either String (Maybe [Label])
-> Either
String
(Maybe OrientationCorrection
-> Maybe Text -> Int -> DetectLabelsResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Either String (Maybe (Maybe [Label]))
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"Labels" Either String (Maybe (Maybe [Label]))
-> Maybe [Label] -> Either String (Maybe [Label])
forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ Maybe [Label]
forall a. Monoid a => a
Prelude.mempty)
Either
String
(Maybe OrientationCorrection
-> Maybe Text -> Int -> DetectLabelsResponse)
-> Either String (Maybe OrientationCorrection)
-> Either String (Maybe Text -> Int -> DetectLabelsResponse)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Either String (Maybe OrientationCorrection)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"OrientationCorrection")
Either String (Maybe Text -> Int -> DetectLabelsResponse)
-> Either String (Maybe Text)
-> Either String (Int -> DetectLabelsResponse)
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
"LabelModelVersion")
Either String (Int -> DetectLabelsResponse)
-> Either String Int -> Either String DetectLabelsResponse
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 DetectLabels
instance Prelude.NFData DetectLabels
instance Core.ToHeaders DetectLabels where
toHeaders :: DetectLabels -> ResponseHeaders
toHeaders =
ResponseHeaders -> DetectLabels -> 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.DetectLabels" ::
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 DetectLabels where
toJSON :: DetectLabels -> Value
toJSON DetectLabels' {Maybe Double
Maybe Natural
Image
image :: Image
maxLabels :: Maybe Natural
minConfidence :: Maybe Double
$sel:image:DetectLabels' :: DetectLabels -> Image
$sel:maxLabels:DetectLabels' :: DetectLabels -> Maybe Natural
$sel:minConfidence:DetectLabels' :: DetectLabels -> Maybe Double
..} =
[Pair] -> Value
Core.object
( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
[ (Text
"MinConfidence" Text -> Double -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Double -> Pair) -> Maybe Double -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Double
minConfidence,
(Text
"MaxLabels" Text -> Natural -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Natural -> Pair) -> Maybe Natural -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Natural
maxLabels,
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 DetectLabels where
toPath :: DetectLabels -> ByteString
toPath = ByteString -> DetectLabels -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/"
instance Core.ToQuery DetectLabels where
toQuery :: DetectLabels -> QueryString
toQuery = QueryString -> DetectLabels -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
forall a. Monoid a => a
Prelude.mempty
data DetectLabelsResponse = DetectLabelsResponse'
{
DetectLabelsResponse -> Maybe [Label]
labels :: Prelude.Maybe [Label],
DetectLabelsResponse -> Maybe OrientationCorrection
orientationCorrection :: Prelude.Maybe OrientationCorrection,
DetectLabelsResponse -> Maybe Text
labelModelVersion :: Prelude.Maybe Prelude.Text,
DetectLabelsResponse -> Int
httpStatus :: Prelude.Int
}
deriving (DetectLabelsResponse -> DetectLabelsResponse -> Bool
(DetectLabelsResponse -> DetectLabelsResponse -> Bool)
-> (DetectLabelsResponse -> DetectLabelsResponse -> Bool)
-> Eq DetectLabelsResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DetectLabelsResponse -> DetectLabelsResponse -> Bool
$c/= :: DetectLabelsResponse -> DetectLabelsResponse -> Bool
== :: DetectLabelsResponse -> DetectLabelsResponse -> Bool
$c== :: DetectLabelsResponse -> DetectLabelsResponse -> Bool
Prelude.Eq, ReadPrec [DetectLabelsResponse]
ReadPrec DetectLabelsResponse
Int -> ReadS DetectLabelsResponse
ReadS [DetectLabelsResponse]
(Int -> ReadS DetectLabelsResponse)
-> ReadS [DetectLabelsResponse]
-> ReadPrec DetectLabelsResponse
-> ReadPrec [DetectLabelsResponse]
-> Read DetectLabelsResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DetectLabelsResponse]
$creadListPrec :: ReadPrec [DetectLabelsResponse]
readPrec :: ReadPrec DetectLabelsResponse
$creadPrec :: ReadPrec DetectLabelsResponse
readList :: ReadS [DetectLabelsResponse]
$creadList :: ReadS [DetectLabelsResponse]
readsPrec :: Int -> ReadS DetectLabelsResponse
$creadsPrec :: Int -> ReadS DetectLabelsResponse
Prelude.Read, Int -> DetectLabelsResponse -> ShowS
[DetectLabelsResponse] -> ShowS
DetectLabelsResponse -> String
(Int -> DetectLabelsResponse -> ShowS)
-> (DetectLabelsResponse -> String)
-> ([DetectLabelsResponse] -> ShowS)
-> Show DetectLabelsResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DetectLabelsResponse] -> ShowS
$cshowList :: [DetectLabelsResponse] -> ShowS
show :: DetectLabelsResponse -> String
$cshow :: DetectLabelsResponse -> String
showsPrec :: Int -> DetectLabelsResponse -> ShowS
$cshowsPrec :: Int -> DetectLabelsResponse -> ShowS
Prelude.Show, (forall x. DetectLabelsResponse -> Rep DetectLabelsResponse x)
-> (forall x. Rep DetectLabelsResponse x -> DetectLabelsResponse)
-> Generic DetectLabelsResponse
forall x. Rep DetectLabelsResponse x -> DetectLabelsResponse
forall x. DetectLabelsResponse -> Rep DetectLabelsResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DetectLabelsResponse x -> DetectLabelsResponse
$cfrom :: forall x. DetectLabelsResponse -> Rep DetectLabelsResponse x
Prelude.Generic)
newDetectLabelsResponse ::
Prelude.Int ->
DetectLabelsResponse
newDetectLabelsResponse :: Int -> DetectLabelsResponse
newDetectLabelsResponse Int
pHttpStatus_ =
DetectLabelsResponse' :: Maybe [Label]
-> Maybe OrientationCorrection
-> Maybe Text
-> Int
-> DetectLabelsResponse
DetectLabelsResponse'
{ $sel:labels:DetectLabelsResponse' :: Maybe [Label]
labels = Maybe [Label]
forall a. Maybe a
Prelude.Nothing,
$sel:orientationCorrection:DetectLabelsResponse' :: Maybe OrientationCorrection
orientationCorrection = Maybe OrientationCorrection
forall a. Maybe a
Prelude.Nothing,
$sel:labelModelVersion:DetectLabelsResponse' :: Maybe Text
labelModelVersion = Maybe Text
forall a. Maybe a
Prelude.Nothing,
$sel:httpStatus:DetectLabelsResponse' :: Int
httpStatus = Int
pHttpStatus_
}
detectLabelsResponse_labels :: Lens.Lens' DetectLabelsResponse (Prelude.Maybe [Label])
detectLabelsResponse_labels :: (Maybe [Label] -> f (Maybe [Label]))
-> DetectLabelsResponse -> f DetectLabelsResponse
detectLabelsResponse_labels = (DetectLabelsResponse -> Maybe [Label])
-> (DetectLabelsResponse -> Maybe [Label] -> DetectLabelsResponse)
-> Lens
DetectLabelsResponse
DetectLabelsResponse
(Maybe [Label])
(Maybe [Label])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DetectLabelsResponse' {Maybe [Label]
labels :: Maybe [Label]
$sel:labels:DetectLabelsResponse' :: DetectLabelsResponse -> Maybe [Label]
labels} -> Maybe [Label]
labels) (\s :: DetectLabelsResponse
s@DetectLabelsResponse' {} Maybe [Label]
a -> DetectLabelsResponse
s {$sel:labels:DetectLabelsResponse' :: Maybe [Label]
labels = Maybe [Label]
a} :: DetectLabelsResponse) ((Maybe [Label] -> f (Maybe [Label]))
-> DetectLabelsResponse -> f DetectLabelsResponse)
-> ((Maybe [Label] -> f (Maybe [Label]))
-> Maybe [Label] -> f (Maybe [Label]))
-> (Maybe [Label] -> f (Maybe [Label]))
-> DetectLabelsResponse
-> f DetectLabelsResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Label] [Label] [Label] [Label]
-> Iso
(Maybe [Label]) (Maybe [Label]) (Maybe [Label]) (Maybe [Label])
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 [Label] [Label] [Label] [Label]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced
detectLabelsResponse_orientationCorrection :: Lens.Lens' DetectLabelsResponse (Prelude.Maybe OrientationCorrection)
detectLabelsResponse_orientationCorrection :: (Maybe OrientationCorrection -> f (Maybe OrientationCorrection))
-> DetectLabelsResponse -> f DetectLabelsResponse
detectLabelsResponse_orientationCorrection = (DetectLabelsResponse -> Maybe OrientationCorrection)
-> (DetectLabelsResponse
-> Maybe OrientationCorrection -> DetectLabelsResponse)
-> Lens
DetectLabelsResponse
DetectLabelsResponse
(Maybe OrientationCorrection)
(Maybe OrientationCorrection)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DetectLabelsResponse' {Maybe OrientationCorrection
orientationCorrection :: Maybe OrientationCorrection
$sel:orientationCorrection:DetectLabelsResponse' :: DetectLabelsResponse -> Maybe OrientationCorrection
orientationCorrection} -> Maybe OrientationCorrection
orientationCorrection) (\s :: DetectLabelsResponse
s@DetectLabelsResponse' {} Maybe OrientationCorrection
a -> DetectLabelsResponse
s {$sel:orientationCorrection:DetectLabelsResponse' :: Maybe OrientationCorrection
orientationCorrection = Maybe OrientationCorrection
a} :: DetectLabelsResponse)
detectLabelsResponse_labelModelVersion :: Lens.Lens' DetectLabelsResponse (Prelude.Maybe Prelude.Text)
detectLabelsResponse_labelModelVersion :: (Maybe Text -> f (Maybe Text))
-> DetectLabelsResponse -> f DetectLabelsResponse
detectLabelsResponse_labelModelVersion = (DetectLabelsResponse -> Maybe Text)
-> (DetectLabelsResponse -> Maybe Text -> DetectLabelsResponse)
-> Lens
DetectLabelsResponse DetectLabelsResponse (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DetectLabelsResponse' {Maybe Text
labelModelVersion :: Maybe Text
$sel:labelModelVersion:DetectLabelsResponse' :: DetectLabelsResponse -> Maybe Text
labelModelVersion} -> Maybe Text
labelModelVersion) (\s :: DetectLabelsResponse
s@DetectLabelsResponse' {} Maybe Text
a -> DetectLabelsResponse
s {$sel:labelModelVersion:DetectLabelsResponse' :: Maybe Text
labelModelVersion = Maybe Text
a} :: DetectLabelsResponse)
detectLabelsResponse_httpStatus :: Lens.Lens' DetectLabelsResponse Prelude.Int
detectLabelsResponse_httpStatus :: (Int -> f Int) -> DetectLabelsResponse -> f DetectLabelsResponse
detectLabelsResponse_httpStatus = (DetectLabelsResponse -> Int)
-> (DetectLabelsResponse -> Int -> DetectLabelsResponse)
-> Lens DetectLabelsResponse DetectLabelsResponse Int Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DetectLabelsResponse' {Int
httpStatus :: Int
$sel:httpStatus:DetectLabelsResponse' :: DetectLabelsResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: DetectLabelsResponse
s@DetectLabelsResponse' {} Int
a -> DetectLabelsResponse
s {$sel:httpStatus:DetectLabelsResponse' :: Int
httpStatus = Int
a} :: DetectLabelsResponse)
instance Prelude.NFData DetectLabelsResponse