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