{-# 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.BatchDetectSentiment
(
BatchDetectSentiment (..),
newBatchDetectSentiment,
batchDetectSentiment_textList,
batchDetectSentiment_languageCode,
BatchDetectSentimentResponse (..),
newBatchDetectSentimentResponse,
batchDetectSentimentResponse_httpStatus,
batchDetectSentimentResponse_resultList,
batchDetectSentimentResponse_errorList,
)
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 BatchDetectSentiment = BatchDetectSentiment'
{
BatchDetectSentiment -> Sensitive [Sensitive Text]
textList :: Core.Sensitive [Core.Sensitive Prelude.Text],
BatchDetectSentiment -> LanguageCode
languageCode :: LanguageCode
}
deriving (BatchDetectSentiment -> BatchDetectSentiment -> Bool
(BatchDetectSentiment -> BatchDetectSentiment -> Bool)
-> (BatchDetectSentiment -> BatchDetectSentiment -> Bool)
-> Eq BatchDetectSentiment
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: BatchDetectSentiment -> BatchDetectSentiment -> Bool
$c/= :: BatchDetectSentiment -> BatchDetectSentiment -> Bool
== :: BatchDetectSentiment -> BatchDetectSentiment -> Bool
$c== :: BatchDetectSentiment -> BatchDetectSentiment -> Bool
Prelude.Eq, Int -> BatchDetectSentiment -> ShowS
[BatchDetectSentiment] -> ShowS
BatchDetectSentiment -> String
(Int -> BatchDetectSentiment -> ShowS)
-> (BatchDetectSentiment -> String)
-> ([BatchDetectSentiment] -> ShowS)
-> Show BatchDetectSentiment
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [BatchDetectSentiment] -> ShowS
$cshowList :: [BatchDetectSentiment] -> ShowS
show :: BatchDetectSentiment -> String
$cshow :: BatchDetectSentiment -> String
showsPrec :: Int -> BatchDetectSentiment -> ShowS
$cshowsPrec :: Int -> BatchDetectSentiment -> ShowS
Prelude.Show, (forall x. BatchDetectSentiment -> Rep BatchDetectSentiment x)
-> (forall x. Rep BatchDetectSentiment x -> BatchDetectSentiment)
-> Generic BatchDetectSentiment
forall x. Rep BatchDetectSentiment x -> BatchDetectSentiment
forall x. BatchDetectSentiment -> Rep BatchDetectSentiment x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep BatchDetectSentiment x -> BatchDetectSentiment
$cfrom :: forall x. BatchDetectSentiment -> Rep BatchDetectSentiment x
Prelude.Generic)
newBatchDetectSentiment ::
LanguageCode ->
BatchDetectSentiment
newBatchDetectSentiment :: LanguageCode -> BatchDetectSentiment
newBatchDetectSentiment LanguageCode
pLanguageCode_ =
BatchDetectSentiment' :: Sensitive [Sensitive Text] -> LanguageCode -> BatchDetectSentiment
BatchDetectSentiment'
{ $sel:textList:BatchDetectSentiment' :: Sensitive [Sensitive Text]
textList = Sensitive [Sensitive Text]
forall a. Monoid a => a
Prelude.mempty,
$sel:languageCode:BatchDetectSentiment' :: LanguageCode
languageCode = LanguageCode
pLanguageCode_
}
batchDetectSentiment_textList :: Lens.Lens' BatchDetectSentiment [Prelude.Text]
batchDetectSentiment_textList :: ([Text] -> f [Text])
-> BatchDetectSentiment -> f BatchDetectSentiment
batchDetectSentiment_textList = (BatchDetectSentiment -> Sensitive [Sensitive Text])
-> (BatchDetectSentiment
-> Sensitive [Sensitive Text] -> BatchDetectSentiment)
-> Lens
BatchDetectSentiment
BatchDetectSentiment
(Sensitive [Sensitive Text])
(Sensitive [Sensitive Text])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BatchDetectSentiment' {Sensitive [Sensitive Text]
textList :: Sensitive [Sensitive Text]
$sel:textList:BatchDetectSentiment' :: BatchDetectSentiment -> Sensitive [Sensitive Text]
textList} -> Sensitive [Sensitive Text]
textList) (\s :: BatchDetectSentiment
s@BatchDetectSentiment' {} Sensitive [Sensitive Text]
a -> BatchDetectSentiment
s {$sel:textList:BatchDetectSentiment' :: Sensitive [Sensitive Text]
textList = Sensitive [Sensitive Text]
a} :: BatchDetectSentiment) ((Sensitive [Sensitive Text] -> f (Sensitive [Sensitive Text]))
-> BatchDetectSentiment -> f BatchDetectSentiment)
-> (([Text] -> f [Text])
-> Sensitive [Sensitive Text] -> f (Sensitive [Sensitive Text]))
-> ([Text] -> f [Text])
-> BatchDetectSentiment
-> f BatchDetectSentiment
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. ([Sensitive Text] -> f [Sensitive Text])
-> Sensitive [Sensitive Text] -> f (Sensitive [Sensitive Text])
forall a. Iso' (Sensitive a) a
Core._Sensitive (([Sensitive Text] -> f [Sensitive Text])
-> Sensitive [Sensitive Text] -> f (Sensitive [Sensitive Text]))
-> (([Text] -> f [Text]) -> [Sensitive Text] -> f [Sensitive Text])
-> ([Text] -> f [Text])
-> Sensitive [Sensitive Text]
-> f (Sensitive [Sensitive Text])
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. ([Text] -> f [Text]) -> [Sensitive Text] -> f [Sensitive Text]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced
batchDetectSentiment_languageCode :: Lens.Lens' BatchDetectSentiment LanguageCode
batchDetectSentiment_languageCode :: (LanguageCode -> f LanguageCode)
-> BatchDetectSentiment -> f BatchDetectSentiment
batchDetectSentiment_languageCode = (BatchDetectSentiment -> LanguageCode)
-> (BatchDetectSentiment -> LanguageCode -> BatchDetectSentiment)
-> Lens
BatchDetectSentiment BatchDetectSentiment LanguageCode LanguageCode
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BatchDetectSentiment' {LanguageCode
languageCode :: LanguageCode
$sel:languageCode:BatchDetectSentiment' :: BatchDetectSentiment -> LanguageCode
languageCode} -> LanguageCode
languageCode) (\s :: BatchDetectSentiment
s@BatchDetectSentiment' {} LanguageCode
a -> BatchDetectSentiment
s {$sel:languageCode:BatchDetectSentiment' :: LanguageCode
languageCode = LanguageCode
a} :: BatchDetectSentiment)
instance Core.AWSRequest BatchDetectSentiment where
type
AWSResponse BatchDetectSentiment =
BatchDetectSentimentResponse
request :: BatchDetectSentiment -> Request BatchDetectSentiment
request = Service -> BatchDetectSentiment -> Request BatchDetectSentiment
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
response :: Logger
-> Service
-> Proxy BatchDetectSentiment
-> ClientResponse ClientBody
-> m (Either
Error (ClientResponse (AWSResponse BatchDetectSentiment)))
response =
(Int
-> ResponseHeaders
-> Object
-> Either String (AWSResponse BatchDetectSentiment))
-> Logger
-> Service
-> Proxy BatchDetectSentiment
-> ClientResponse ClientBody
-> m (Either
Error (ClientResponse (AWSResponse BatchDetectSentiment)))
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 ->
Int
-> [BatchDetectSentimentItemResult]
-> [BatchItemError]
-> BatchDetectSentimentResponse
BatchDetectSentimentResponse'
(Int
-> [BatchDetectSentimentItemResult]
-> [BatchItemError]
-> BatchDetectSentimentResponse)
-> Either String Int
-> Either
String
([BatchDetectSentimentItemResult]
-> [BatchItemError] -> BatchDetectSentimentResponse)
forall (f :: * -> *) a b. Functor 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))
Either
String
([BatchDetectSentimentItemResult]
-> [BatchItemError] -> BatchDetectSentimentResponse)
-> Either String [BatchDetectSentimentItemResult]
-> Either String ([BatchItemError] -> BatchDetectSentimentResponse)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object
-> Text -> Either String (Maybe [BatchDetectSentimentItemResult])
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"ResultList" Either String (Maybe [BatchDetectSentimentItemResult])
-> [BatchDetectSentimentItemResult]
-> Either String [BatchDetectSentimentItemResult]
forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ [BatchDetectSentimentItemResult]
forall a. Monoid a => a
Prelude.mempty)
Either String ([BatchItemError] -> BatchDetectSentimentResponse)
-> Either String [BatchItemError]
-> Either String BatchDetectSentimentResponse
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Either String (Maybe [BatchItemError])
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"ErrorList" Either String (Maybe [BatchItemError])
-> [BatchItemError] -> Either String [BatchItemError]
forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ [BatchItemError]
forall a. Monoid a => a
Prelude.mempty)
)
instance Prelude.Hashable BatchDetectSentiment
instance Prelude.NFData BatchDetectSentiment
instance Core.ToHeaders BatchDetectSentiment where
toHeaders :: BatchDetectSentiment -> ResponseHeaders
toHeaders =
ResponseHeaders -> BatchDetectSentiment -> 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.BatchDetectSentiment" ::
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 BatchDetectSentiment where
toJSON :: BatchDetectSentiment -> Value
toJSON BatchDetectSentiment' {Sensitive [Sensitive Text]
LanguageCode
languageCode :: LanguageCode
textList :: Sensitive [Sensitive Text]
$sel:languageCode:BatchDetectSentiment' :: BatchDetectSentiment -> LanguageCode
$sel:textList:BatchDetectSentiment' :: BatchDetectSentiment -> Sensitive [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
"TextList" Text -> Sensitive [Sensitive Text] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Sensitive [Sensitive Text]
textList),
Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"LanguageCode" Text -> LanguageCode -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= LanguageCode
languageCode)
]
)
instance Core.ToPath BatchDetectSentiment where
toPath :: BatchDetectSentiment -> ByteString
toPath = ByteString -> BatchDetectSentiment -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/"
instance Core.ToQuery BatchDetectSentiment where
toQuery :: BatchDetectSentiment -> QueryString
toQuery = QueryString -> BatchDetectSentiment -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
forall a. Monoid a => a
Prelude.mempty
data BatchDetectSentimentResponse = BatchDetectSentimentResponse'
{
BatchDetectSentimentResponse -> Int
httpStatus :: Prelude.Int,
BatchDetectSentimentResponse -> [BatchDetectSentimentItemResult]
resultList :: [BatchDetectSentimentItemResult],
BatchDetectSentimentResponse -> [BatchItemError]
errorList :: [BatchItemError]
}
deriving (BatchDetectSentimentResponse
-> BatchDetectSentimentResponse -> Bool
(BatchDetectSentimentResponse
-> BatchDetectSentimentResponse -> Bool)
-> (BatchDetectSentimentResponse
-> BatchDetectSentimentResponse -> Bool)
-> Eq BatchDetectSentimentResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: BatchDetectSentimentResponse
-> BatchDetectSentimentResponse -> Bool
$c/= :: BatchDetectSentimentResponse
-> BatchDetectSentimentResponse -> Bool
== :: BatchDetectSentimentResponse
-> BatchDetectSentimentResponse -> Bool
$c== :: BatchDetectSentimentResponse
-> BatchDetectSentimentResponse -> Bool
Prelude.Eq, Int -> BatchDetectSentimentResponse -> ShowS
[BatchDetectSentimentResponse] -> ShowS
BatchDetectSentimentResponse -> String
(Int -> BatchDetectSentimentResponse -> ShowS)
-> (BatchDetectSentimentResponse -> String)
-> ([BatchDetectSentimentResponse] -> ShowS)
-> Show BatchDetectSentimentResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [BatchDetectSentimentResponse] -> ShowS
$cshowList :: [BatchDetectSentimentResponse] -> ShowS
show :: BatchDetectSentimentResponse -> String
$cshow :: BatchDetectSentimentResponse -> String
showsPrec :: Int -> BatchDetectSentimentResponse -> ShowS
$cshowsPrec :: Int -> BatchDetectSentimentResponse -> ShowS
Prelude.Show, (forall x.
BatchDetectSentimentResponse -> Rep BatchDetectSentimentResponse x)
-> (forall x.
Rep BatchDetectSentimentResponse x -> BatchDetectSentimentResponse)
-> Generic BatchDetectSentimentResponse
forall x.
Rep BatchDetectSentimentResponse x -> BatchDetectSentimentResponse
forall x.
BatchDetectSentimentResponse -> Rep BatchDetectSentimentResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep BatchDetectSentimentResponse x -> BatchDetectSentimentResponse
$cfrom :: forall x.
BatchDetectSentimentResponse -> Rep BatchDetectSentimentResponse x
Prelude.Generic)
newBatchDetectSentimentResponse ::
Prelude.Int ->
BatchDetectSentimentResponse
newBatchDetectSentimentResponse :: Int -> BatchDetectSentimentResponse
newBatchDetectSentimentResponse Int
pHttpStatus_ =
BatchDetectSentimentResponse' :: Int
-> [BatchDetectSentimentItemResult]
-> [BatchItemError]
-> BatchDetectSentimentResponse
BatchDetectSentimentResponse'
{ $sel:httpStatus:BatchDetectSentimentResponse' :: Int
httpStatus =
Int
pHttpStatus_,
$sel:resultList:BatchDetectSentimentResponse' :: [BatchDetectSentimentItemResult]
resultList = [BatchDetectSentimentItemResult]
forall a. Monoid a => a
Prelude.mempty,
$sel:errorList:BatchDetectSentimentResponse' :: [BatchItemError]
errorList = [BatchItemError]
forall a. Monoid a => a
Prelude.mempty
}
batchDetectSentimentResponse_httpStatus :: Lens.Lens' BatchDetectSentimentResponse Prelude.Int
batchDetectSentimentResponse_httpStatus :: (Int -> f Int)
-> BatchDetectSentimentResponse -> f BatchDetectSentimentResponse
batchDetectSentimentResponse_httpStatus = (BatchDetectSentimentResponse -> Int)
-> (BatchDetectSentimentResponse
-> Int -> BatchDetectSentimentResponse)
-> Lens
BatchDetectSentimentResponse BatchDetectSentimentResponse Int Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BatchDetectSentimentResponse' {Int
httpStatus :: Int
$sel:httpStatus:BatchDetectSentimentResponse' :: BatchDetectSentimentResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: BatchDetectSentimentResponse
s@BatchDetectSentimentResponse' {} Int
a -> BatchDetectSentimentResponse
s {$sel:httpStatus:BatchDetectSentimentResponse' :: Int
httpStatus = Int
a} :: BatchDetectSentimentResponse)
batchDetectSentimentResponse_resultList :: Lens.Lens' BatchDetectSentimentResponse [BatchDetectSentimentItemResult]
batchDetectSentimentResponse_resultList :: ([BatchDetectSentimentItemResult]
-> f [BatchDetectSentimentItemResult])
-> BatchDetectSentimentResponse -> f BatchDetectSentimentResponse
batchDetectSentimentResponse_resultList = (BatchDetectSentimentResponse -> [BatchDetectSentimentItemResult])
-> (BatchDetectSentimentResponse
-> [BatchDetectSentimentItemResult]
-> BatchDetectSentimentResponse)
-> Lens
BatchDetectSentimentResponse
BatchDetectSentimentResponse
[BatchDetectSentimentItemResult]
[BatchDetectSentimentItemResult]
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BatchDetectSentimentResponse' {[BatchDetectSentimentItemResult]
resultList :: [BatchDetectSentimentItemResult]
$sel:resultList:BatchDetectSentimentResponse' :: BatchDetectSentimentResponse -> [BatchDetectSentimentItemResult]
resultList} -> [BatchDetectSentimentItemResult]
resultList) (\s :: BatchDetectSentimentResponse
s@BatchDetectSentimentResponse' {} [BatchDetectSentimentItemResult]
a -> BatchDetectSentimentResponse
s {$sel:resultList:BatchDetectSentimentResponse' :: [BatchDetectSentimentItemResult]
resultList = [BatchDetectSentimentItemResult]
a} :: BatchDetectSentimentResponse) (([BatchDetectSentimentItemResult]
-> f [BatchDetectSentimentItemResult])
-> BatchDetectSentimentResponse -> f BatchDetectSentimentResponse)
-> (([BatchDetectSentimentItemResult]
-> f [BatchDetectSentimentItemResult])
-> [BatchDetectSentimentItemResult]
-> f [BatchDetectSentimentItemResult])
-> ([BatchDetectSentimentItemResult]
-> f [BatchDetectSentimentItemResult])
-> BatchDetectSentimentResponse
-> f BatchDetectSentimentResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. ([BatchDetectSentimentItemResult]
-> f [BatchDetectSentimentItemResult])
-> [BatchDetectSentimentItemResult]
-> f [BatchDetectSentimentItemResult]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced
batchDetectSentimentResponse_errorList :: Lens.Lens' BatchDetectSentimentResponse [BatchItemError]
batchDetectSentimentResponse_errorList :: ([BatchItemError] -> f [BatchItemError])
-> BatchDetectSentimentResponse -> f BatchDetectSentimentResponse
batchDetectSentimentResponse_errorList = (BatchDetectSentimentResponse -> [BatchItemError])
-> (BatchDetectSentimentResponse
-> [BatchItemError] -> BatchDetectSentimentResponse)
-> Lens
BatchDetectSentimentResponse
BatchDetectSentimentResponse
[BatchItemError]
[BatchItemError]
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BatchDetectSentimentResponse' {[BatchItemError]
errorList :: [BatchItemError]
$sel:errorList:BatchDetectSentimentResponse' :: BatchDetectSentimentResponse -> [BatchItemError]
errorList} -> [BatchItemError]
errorList) (\s :: BatchDetectSentimentResponse
s@BatchDetectSentimentResponse' {} [BatchItemError]
a -> BatchDetectSentimentResponse
s {$sel:errorList:BatchDetectSentimentResponse' :: [BatchItemError]
errorList = [BatchItemError]
a} :: BatchDetectSentimentResponse) (([BatchItemError] -> f [BatchItemError])
-> BatchDetectSentimentResponse -> f BatchDetectSentimentResponse)
-> (([BatchItemError] -> f [BatchItemError])
-> [BatchItemError] -> f [BatchItemError])
-> ([BatchItemError] -> f [BatchItemError])
-> BatchDetectSentimentResponse
-> f BatchDetectSentimentResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. ([BatchItemError] -> f [BatchItemError])
-> [BatchItemError] -> f [BatchItemError]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced
instance Prelude.NFData BatchDetectSentimentResponse