{-# 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.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
data BatchDetectSentiment = BatchDetectSentiment'
{
BatchDetectSentiment -> Sensitive (NonEmpty (Sensitive Text))
textList :: Data.Sensitive (Prelude.NonEmpty (Data.Sensitive Prelude.Text)),
BatchDetectSentiment -> LanguageCode
languageCode :: LanguageCode
}
deriving (BatchDetectSentiment -> BatchDetectSentiment -> Bool
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
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. 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 ::
Prelude.NonEmpty Prelude.Text ->
LanguageCode ->
BatchDetectSentiment
newBatchDetectSentiment :: NonEmpty Text -> LanguageCode -> BatchDetectSentiment
newBatchDetectSentiment NonEmpty Text
pTextList_ LanguageCode
pLanguageCode_ =
BatchDetectSentiment'
{ $sel:textList:BatchDetectSentiment' :: Sensitive (NonEmpty (Sensitive Text))
textList =
forall a. Iso' (Sensitive a) a
Data._Sensitive
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced
forall t b. AReview t b -> b -> t
Lens.# NonEmpty Text
pTextList_,
$sel:languageCode:BatchDetectSentiment' :: LanguageCode
languageCode = LanguageCode
pLanguageCode_
}
batchDetectSentiment_textList :: Lens.Lens' BatchDetectSentiment (Prelude.NonEmpty Prelude.Text)
batchDetectSentiment_textList :: Lens' BatchDetectSentiment (NonEmpty Text)
batchDetectSentiment_textList = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BatchDetectSentiment' {Sensitive (NonEmpty (Sensitive Text))
textList :: Sensitive (NonEmpty (Sensitive Text))
$sel:textList:BatchDetectSentiment' :: BatchDetectSentiment -> Sensitive (NonEmpty (Sensitive Text))
textList} -> Sensitive (NonEmpty (Sensitive Text))
textList) (\s :: BatchDetectSentiment
s@BatchDetectSentiment' {} Sensitive (NonEmpty (Sensitive Text))
a -> BatchDetectSentiment
s {$sel:textList:BatchDetectSentiment' :: Sensitive (NonEmpty (Sensitive Text))
textList = Sensitive (NonEmpty (Sensitive Text))
a} :: BatchDetectSentiment) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall a. Iso' (Sensitive a) a
Data._Sensitive forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. 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 :: Lens' BatchDetectSentiment LanguageCode
batchDetectSentiment_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 :: (Service -> Service)
-> BatchDetectSentiment -> Request BatchDetectSentiment
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 BatchDetectSentiment
-> ClientResponse ClientBody
-> m (Either
Error (ClientResponse (AWSResponse BatchDetectSentiment)))
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 ->
Int
-> [BatchDetectSentimentItemResult]
-> [BatchItemError]
-> BatchDetectSentimentResponse
BatchDetectSentimentResponse'
forall (f :: * -> *) a b. Functor 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))
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
"ResultList" 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
"ErrorList" forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ forall a. Monoid a => a
Prelude.mempty)
)
instance Prelude.Hashable BatchDetectSentiment where
hashWithSalt :: Int -> BatchDetectSentiment -> Int
hashWithSalt Int
_salt BatchDetectSentiment' {Sensitive (NonEmpty (Sensitive Text))
LanguageCode
languageCode :: LanguageCode
textList :: Sensitive (NonEmpty (Sensitive Text))
$sel:languageCode:BatchDetectSentiment' :: BatchDetectSentiment -> LanguageCode
$sel:textList:BatchDetectSentiment' :: BatchDetectSentiment -> Sensitive (NonEmpty (Sensitive Text))
..} =
Int
_salt
forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Sensitive (NonEmpty (Sensitive Text))
textList
forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` LanguageCode
languageCode
instance Prelude.NFData BatchDetectSentiment where
rnf :: BatchDetectSentiment -> ()
rnf BatchDetectSentiment' {Sensitive (NonEmpty (Sensitive Text))
LanguageCode
languageCode :: LanguageCode
textList :: Sensitive (NonEmpty (Sensitive Text))
$sel:languageCode:BatchDetectSentiment' :: BatchDetectSentiment -> LanguageCode
$sel:textList:BatchDetectSentiment' :: BatchDetectSentiment -> Sensitive (NonEmpty (Sensitive Text))
..} =
forall a. NFData a => a -> ()
Prelude.rnf Sensitive (NonEmpty (Sensitive Text))
textList
seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf LanguageCode
languageCode
instance Data.ToHeaders BatchDetectSentiment where
toHeaders :: BatchDetectSentiment -> 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
"Comprehend_20171127.BatchDetectSentiment" ::
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 BatchDetectSentiment where
toJSON :: BatchDetectSentiment -> Value
toJSON BatchDetectSentiment' {Sensitive (NonEmpty (Sensitive Text))
LanguageCode
languageCode :: LanguageCode
textList :: Sensitive (NonEmpty (Sensitive Text))
$sel:languageCode:BatchDetectSentiment' :: BatchDetectSentiment -> LanguageCode
$sel:textList:BatchDetectSentiment' :: BatchDetectSentiment -> Sensitive (NonEmpty (Sensitive Text))
..} =
[Pair] -> Value
Data.object
( forall a. [Maybe a] -> [a]
Prelude.catMaybes
[ forall a. a -> Maybe a
Prelude.Just (Key
"TextList" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Sensitive (NonEmpty (Sensitive Text))
textList),
forall a. a -> Maybe a
Prelude.Just (Key
"LanguageCode" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= LanguageCode
languageCode)
]
)
instance Data.ToPath BatchDetectSentiment where
toPath :: BatchDetectSentiment -> ByteString
toPath = forall a b. a -> b -> a
Prelude.const ByteString
"/"
instance Data.ToQuery BatchDetectSentiment where
toQuery :: BatchDetectSentiment -> QueryString
toQuery = forall a b. a -> b -> a
Prelude.const 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
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
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.
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'
{ $sel:httpStatus:BatchDetectSentimentResponse' :: Int
httpStatus =
Int
pHttpStatus_,
$sel:resultList:BatchDetectSentimentResponse' :: [BatchDetectSentimentItemResult]
resultList = forall a. Monoid a => a
Prelude.mempty,
$sel:errorList:BatchDetectSentimentResponse' :: [BatchItemError]
errorList = forall a. Monoid a => a
Prelude.mempty
}
batchDetectSentimentResponse_httpStatus :: Lens.Lens' BatchDetectSentimentResponse Prelude.Int
batchDetectSentimentResponse_httpStatus :: Lens' BatchDetectSentimentResponse Int
batchDetectSentimentResponse_httpStatus = 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 :: Lens' BatchDetectSentimentResponse [BatchDetectSentimentItemResult]
batchDetectSentimentResponse_resultList = 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) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. 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 :: Lens' BatchDetectSentimentResponse [BatchItemError]
batchDetectSentimentResponse_errorList = 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) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced
instance Prelude.NFData BatchDetectSentimentResponse where
rnf :: BatchDetectSentimentResponse -> ()
rnf BatchDetectSentimentResponse' {Int
[BatchItemError]
[BatchDetectSentimentItemResult]
errorList :: [BatchItemError]
resultList :: [BatchDetectSentimentItemResult]
httpStatus :: Int
$sel:errorList:BatchDetectSentimentResponse' :: BatchDetectSentimentResponse -> [BatchItemError]
$sel:resultList:BatchDetectSentimentResponse' :: BatchDetectSentimentResponse -> [BatchDetectSentimentItemResult]
$sel:httpStatus:BatchDetectSentimentResponse' :: BatchDetectSentimentResponse -> Int
..} =
forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus
seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf [BatchDetectSentimentItemResult]
resultList
seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf [BatchItemError]
errorList