{-# LANGUAGE DeriveDataTypeable #-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE TypeFamilies #-}
{-# OPTIONS_GHC -fno-warn-unused-imports #-}
{-# OPTIONS_GHC -fno-warn-unused-binds #-}
{-# OPTIONS_GHC -fno-warn-unused-matches #-}
module Network.AWS.Comprehend.DetectKeyPhrases
(
detectKeyPhrases
, DetectKeyPhrases
, dkpText
, dkpLanguageCode
, detectKeyPhrasesResponse
, DetectKeyPhrasesResponse
, dkprsKeyPhrases
, dkprsResponseStatus
) where
import Network.AWS.Comprehend.Types
import Network.AWS.Comprehend.Types.Product
import Network.AWS.Lens
import Network.AWS.Prelude
import Network.AWS.Request
import Network.AWS.Response
data DetectKeyPhrases = DetectKeyPhrases'
{ _dkpText :: !Text
, _dkpLanguageCode :: !LanguageCode
} deriving (Eq, Read, Show, Data, Typeable, Generic)
detectKeyPhrases
:: Text
-> LanguageCode
-> DetectKeyPhrases
detectKeyPhrases pText_ pLanguageCode_ =
DetectKeyPhrases' {_dkpText = pText_, _dkpLanguageCode = pLanguageCode_}
dkpText :: Lens' DetectKeyPhrases Text
dkpText = lens _dkpText (\ s a -> s{_dkpText = a})
dkpLanguageCode :: Lens' DetectKeyPhrases LanguageCode
dkpLanguageCode = lens _dkpLanguageCode (\ s a -> s{_dkpLanguageCode = a})
instance AWSRequest DetectKeyPhrases where
type Rs DetectKeyPhrases = DetectKeyPhrasesResponse
request = postJSON comprehend
response
= receiveJSON
(\ s h x ->
DetectKeyPhrasesResponse' <$>
(x .?> "KeyPhrases" .!@ mempty) <*>
(pure (fromEnum s)))
instance Hashable DetectKeyPhrases where
instance NFData DetectKeyPhrases where
instance ToHeaders DetectKeyPhrases where
toHeaders
= const
(mconcat
["X-Amz-Target" =#
("Comprehend_20171127.DetectKeyPhrases" ::
ByteString),
"Content-Type" =#
("application/x-amz-json-1.1" :: ByteString)])
instance ToJSON DetectKeyPhrases where
toJSON DetectKeyPhrases'{..}
= object
(catMaybes
[Just ("Text" .= _dkpText),
Just ("LanguageCode" .= _dkpLanguageCode)])
instance ToPath DetectKeyPhrases where
toPath = const "/"
instance ToQuery DetectKeyPhrases where
toQuery = const mempty
data DetectKeyPhrasesResponse = DetectKeyPhrasesResponse'
{ _dkprsKeyPhrases :: !(Maybe [KeyPhrase])
, _dkprsResponseStatus :: !Int
} deriving (Eq, Read, Show, Data, Typeable, Generic)
detectKeyPhrasesResponse
:: Int
-> DetectKeyPhrasesResponse
detectKeyPhrasesResponse pResponseStatus_ =
DetectKeyPhrasesResponse'
{_dkprsKeyPhrases = Nothing, _dkprsResponseStatus = pResponseStatus_}
dkprsKeyPhrases :: Lens' DetectKeyPhrasesResponse [KeyPhrase]
dkprsKeyPhrases = lens _dkprsKeyPhrases (\ s a -> s{_dkprsKeyPhrases = a}) . _Default . _Coerce
dkprsResponseStatus :: Lens' DetectKeyPhrasesResponse Int
dkprsResponseStatus = lens _dkprsResponseStatus (\ s a -> s{_dkprsResponseStatus = a})
instance NFData DetectKeyPhrasesResponse where