{-# 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.DetectDominantLanguage
(
DetectDominantLanguage (..),
newDetectDominantLanguage,
detectDominantLanguage_text,
DetectDominantLanguageResponse (..),
newDetectDominantLanguageResponse,
detectDominantLanguageResponse_languages,
detectDominantLanguageResponse_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 DetectDominantLanguage = DetectDominantLanguage'
{
DetectDominantLanguage -> Sensitive Text
text :: Core.Sensitive Prelude.Text
}
deriving (DetectDominantLanguage -> DetectDominantLanguage -> Bool
(DetectDominantLanguage -> DetectDominantLanguage -> Bool)
-> (DetectDominantLanguage -> DetectDominantLanguage -> Bool)
-> Eq DetectDominantLanguage
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DetectDominantLanguage -> DetectDominantLanguage -> Bool
$c/= :: DetectDominantLanguage -> DetectDominantLanguage -> Bool
== :: DetectDominantLanguage -> DetectDominantLanguage -> Bool
$c== :: DetectDominantLanguage -> DetectDominantLanguage -> Bool
Prelude.Eq, Int -> DetectDominantLanguage -> ShowS
[DetectDominantLanguage] -> ShowS
DetectDominantLanguage -> String
(Int -> DetectDominantLanguage -> ShowS)
-> (DetectDominantLanguage -> String)
-> ([DetectDominantLanguage] -> ShowS)
-> Show DetectDominantLanguage
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DetectDominantLanguage] -> ShowS
$cshowList :: [DetectDominantLanguage] -> ShowS
show :: DetectDominantLanguage -> String
$cshow :: DetectDominantLanguage -> String
showsPrec :: Int -> DetectDominantLanguage -> ShowS
$cshowsPrec :: Int -> DetectDominantLanguage -> ShowS
Prelude.Show, (forall x. DetectDominantLanguage -> Rep DetectDominantLanguage x)
-> (forall x.
Rep DetectDominantLanguage x -> DetectDominantLanguage)
-> Generic DetectDominantLanguage
forall x. Rep DetectDominantLanguage x -> DetectDominantLanguage
forall x. DetectDominantLanguage -> Rep DetectDominantLanguage x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DetectDominantLanguage x -> DetectDominantLanguage
$cfrom :: forall x. DetectDominantLanguage -> Rep DetectDominantLanguage x
Prelude.Generic)
newDetectDominantLanguage ::
Prelude.Text ->
DetectDominantLanguage
newDetectDominantLanguage :: Text -> DetectDominantLanguage
newDetectDominantLanguage Text
pText_ =
DetectDominantLanguage' :: Sensitive Text -> DetectDominantLanguage
DetectDominantLanguage'
{ $sel:text:DetectDominantLanguage' :: 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_
}
detectDominantLanguage_text :: Lens.Lens' DetectDominantLanguage Prelude.Text
detectDominantLanguage_text :: (Text -> f Text)
-> DetectDominantLanguage -> f DetectDominantLanguage
detectDominantLanguage_text = (DetectDominantLanguage -> Sensitive Text)
-> (DetectDominantLanguage
-> Sensitive Text -> DetectDominantLanguage)
-> Lens
DetectDominantLanguage
DetectDominantLanguage
(Sensitive Text)
(Sensitive Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DetectDominantLanguage' {Sensitive Text
text :: Sensitive Text
$sel:text:DetectDominantLanguage' :: DetectDominantLanguage -> Sensitive Text
text} -> Sensitive Text
text) (\s :: DetectDominantLanguage
s@DetectDominantLanguage' {} Sensitive Text
a -> DetectDominantLanguage
s {$sel:text:DetectDominantLanguage' :: Sensitive Text
text = Sensitive Text
a} :: DetectDominantLanguage) ((Sensitive Text -> f (Sensitive Text))
-> DetectDominantLanguage -> f DetectDominantLanguage)
-> ((Text -> f Text) -> Sensitive Text -> f (Sensitive Text))
-> (Text -> f Text)
-> DetectDominantLanguage
-> f DetectDominantLanguage
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
instance Core.AWSRequest DetectDominantLanguage where
type
AWSResponse DetectDominantLanguage =
DetectDominantLanguageResponse
request :: DetectDominantLanguage -> Request DetectDominantLanguage
request = Service -> DetectDominantLanguage -> Request DetectDominantLanguage
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
response :: Logger
-> Service
-> Proxy DetectDominantLanguage
-> ClientResponse ClientBody
-> m (Either
Error (ClientResponse (AWSResponse DetectDominantLanguage)))
response =
(Int
-> ResponseHeaders
-> Object
-> Either String (AWSResponse DetectDominantLanguage))
-> Logger
-> Service
-> Proxy DetectDominantLanguage
-> ClientResponse ClientBody
-> m (Either
Error (ClientResponse (AWSResponse DetectDominantLanguage)))
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 [DominantLanguage] -> Int -> DetectDominantLanguageResponse
DetectDominantLanguageResponse'
(Maybe [DominantLanguage] -> Int -> DetectDominantLanguageResponse)
-> Either String (Maybe [DominantLanguage])
-> Either String (Int -> DetectDominantLanguageResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Either String (Maybe (Maybe [DominantLanguage]))
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"Languages" Either String (Maybe (Maybe [DominantLanguage]))
-> Maybe [DominantLanguage]
-> Either String (Maybe [DominantLanguage])
forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ Maybe [DominantLanguage]
forall a. Monoid a => a
Prelude.mempty)
Either String (Int -> DetectDominantLanguageResponse)
-> Either String Int
-> Either String DetectDominantLanguageResponse
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 DetectDominantLanguage
instance Prelude.NFData DetectDominantLanguage
instance Core.ToHeaders DetectDominantLanguage where
toHeaders :: DetectDominantLanguage -> ResponseHeaders
toHeaders =
ResponseHeaders -> DetectDominantLanguage -> 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.DetectDominantLanguage" ::
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 DetectDominantLanguage where
toJSON :: DetectDominantLanguage -> Value
toJSON DetectDominantLanguage' {Sensitive Text
text :: Sensitive Text
$sel:text:DetectDominantLanguage' :: DetectDominantLanguage -> 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)]
)
instance Core.ToPath DetectDominantLanguage where
toPath :: DetectDominantLanguage -> ByteString
toPath = ByteString -> DetectDominantLanguage -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/"
instance Core.ToQuery DetectDominantLanguage where
toQuery :: DetectDominantLanguage -> QueryString
toQuery = QueryString -> DetectDominantLanguage -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
forall a. Monoid a => a
Prelude.mempty
data DetectDominantLanguageResponse = DetectDominantLanguageResponse'
{
DetectDominantLanguageResponse -> Maybe [DominantLanguage]
languages :: Prelude.Maybe [DominantLanguage],
DetectDominantLanguageResponse -> Int
httpStatus :: Prelude.Int
}
deriving (DetectDominantLanguageResponse
-> DetectDominantLanguageResponse -> Bool
(DetectDominantLanguageResponse
-> DetectDominantLanguageResponse -> Bool)
-> (DetectDominantLanguageResponse
-> DetectDominantLanguageResponse -> Bool)
-> Eq DetectDominantLanguageResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DetectDominantLanguageResponse
-> DetectDominantLanguageResponse -> Bool
$c/= :: DetectDominantLanguageResponse
-> DetectDominantLanguageResponse -> Bool
== :: DetectDominantLanguageResponse
-> DetectDominantLanguageResponse -> Bool
$c== :: DetectDominantLanguageResponse
-> DetectDominantLanguageResponse -> Bool
Prelude.Eq, Int -> DetectDominantLanguageResponse -> ShowS
[DetectDominantLanguageResponse] -> ShowS
DetectDominantLanguageResponse -> String
(Int -> DetectDominantLanguageResponse -> ShowS)
-> (DetectDominantLanguageResponse -> String)
-> ([DetectDominantLanguageResponse] -> ShowS)
-> Show DetectDominantLanguageResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DetectDominantLanguageResponse] -> ShowS
$cshowList :: [DetectDominantLanguageResponse] -> ShowS
show :: DetectDominantLanguageResponse -> String
$cshow :: DetectDominantLanguageResponse -> String
showsPrec :: Int -> DetectDominantLanguageResponse -> ShowS
$cshowsPrec :: Int -> DetectDominantLanguageResponse -> ShowS
Prelude.Show, (forall x.
DetectDominantLanguageResponse
-> Rep DetectDominantLanguageResponse x)
-> (forall x.
Rep DetectDominantLanguageResponse x
-> DetectDominantLanguageResponse)
-> Generic DetectDominantLanguageResponse
forall x.
Rep DetectDominantLanguageResponse x
-> DetectDominantLanguageResponse
forall x.
DetectDominantLanguageResponse
-> Rep DetectDominantLanguageResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep DetectDominantLanguageResponse x
-> DetectDominantLanguageResponse
$cfrom :: forall x.
DetectDominantLanguageResponse
-> Rep DetectDominantLanguageResponse x
Prelude.Generic)
newDetectDominantLanguageResponse ::
Prelude.Int ->
DetectDominantLanguageResponse
newDetectDominantLanguageResponse :: Int -> DetectDominantLanguageResponse
newDetectDominantLanguageResponse Int
pHttpStatus_ =
DetectDominantLanguageResponse' :: Maybe [DominantLanguage] -> Int -> DetectDominantLanguageResponse
DetectDominantLanguageResponse'
{ $sel:languages:DetectDominantLanguageResponse' :: Maybe [DominantLanguage]
languages =
Maybe [DominantLanguage]
forall a. Maybe a
Prelude.Nothing,
$sel:httpStatus:DetectDominantLanguageResponse' :: Int
httpStatus = Int
pHttpStatus_
}
detectDominantLanguageResponse_languages :: Lens.Lens' DetectDominantLanguageResponse (Prelude.Maybe [DominantLanguage])
detectDominantLanguageResponse_languages :: (Maybe [DominantLanguage] -> f (Maybe [DominantLanguage]))
-> DetectDominantLanguageResponse
-> f DetectDominantLanguageResponse
detectDominantLanguageResponse_languages = (DetectDominantLanguageResponse -> Maybe [DominantLanguage])
-> (DetectDominantLanguageResponse
-> Maybe [DominantLanguage] -> DetectDominantLanguageResponse)
-> Lens
DetectDominantLanguageResponse
DetectDominantLanguageResponse
(Maybe [DominantLanguage])
(Maybe [DominantLanguage])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DetectDominantLanguageResponse' {Maybe [DominantLanguage]
languages :: Maybe [DominantLanguage]
$sel:languages:DetectDominantLanguageResponse' :: DetectDominantLanguageResponse -> Maybe [DominantLanguage]
languages} -> Maybe [DominantLanguage]
languages) (\s :: DetectDominantLanguageResponse
s@DetectDominantLanguageResponse' {} Maybe [DominantLanguage]
a -> DetectDominantLanguageResponse
s {$sel:languages:DetectDominantLanguageResponse' :: Maybe [DominantLanguage]
languages = Maybe [DominantLanguage]
a} :: DetectDominantLanguageResponse) ((Maybe [DominantLanguage] -> f (Maybe [DominantLanguage]))
-> DetectDominantLanguageResponse
-> f DetectDominantLanguageResponse)
-> ((Maybe [DominantLanguage] -> f (Maybe [DominantLanguage]))
-> Maybe [DominantLanguage] -> f (Maybe [DominantLanguage]))
-> (Maybe [DominantLanguage] -> f (Maybe [DominantLanguage]))
-> DetectDominantLanguageResponse
-> f DetectDominantLanguageResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
[DominantLanguage]
[DominantLanguage]
[DominantLanguage]
[DominantLanguage]
-> Iso
(Maybe [DominantLanguage])
(Maybe [DominantLanguage])
(Maybe [DominantLanguage])
(Maybe [DominantLanguage])
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
[DominantLanguage]
[DominantLanguage]
[DominantLanguage]
[DominantLanguage]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced
detectDominantLanguageResponse_httpStatus :: Lens.Lens' DetectDominantLanguageResponse Prelude.Int
detectDominantLanguageResponse_httpStatus :: (Int -> f Int)
-> DetectDominantLanguageResponse
-> f DetectDominantLanguageResponse
detectDominantLanguageResponse_httpStatus = (DetectDominantLanguageResponse -> Int)
-> (DetectDominantLanguageResponse
-> Int -> DetectDominantLanguageResponse)
-> Lens
DetectDominantLanguageResponse
DetectDominantLanguageResponse
Int
Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DetectDominantLanguageResponse' {Int
httpStatus :: Int
$sel:httpStatus:DetectDominantLanguageResponse' :: DetectDominantLanguageResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: DetectDominantLanguageResponse
s@DetectDominantLanguageResponse' {} Int
a -> DetectDominantLanguageResponse
s {$sel:httpStatus:DetectDominantLanguageResponse' :: Int
httpStatus = Int
a} :: DetectDominantLanguageResponse)
instance
Prelude.NFData
DetectDominantLanguageResponse