{-# 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.DetectDominantLanguage
(
detectDominantLanguage
, DetectDominantLanguage
, ddlText
, detectDominantLanguageResponse
, DetectDominantLanguageResponse
, ddlrsLanguages
, ddlrsResponseStatus
) 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
newtype DetectDominantLanguage = DetectDominantLanguage'
{ _ddlText :: Text
} deriving (Eq, Read, Show, Data, Typeable, Generic)
detectDominantLanguage
:: Text
-> DetectDominantLanguage
detectDominantLanguage pText_ = DetectDominantLanguage' {_ddlText = pText_}
ddlText :: Lens' DetectDominantLanguage Text
ddlText = lens _ddlText (\ s a -> s{_ddlText = a})
instance AWSRequest DetectDominantLanguage where
type Rs DetectDominantLanguage =
DetectDominantLanguageResponse
request = postJSON comprehend
response
= receiveJSON
(\ s h x ->
DetectDominantLanguageResponse' <$>
(x .?> "Languages" .!@ mempty) <*>
(pure (fromEnum s)))
instance Hashable DetectDominantLanguage where
instance NFData DetectDominantLanguage where
instance ToHeaders DetectDominantLanguage where
toHeaders
= const
(mconcat
["X-Amz-Target" =#
("Comprehend_20171127.DetectDominantLanguage" ::
ByteString),
"Content-Type" =#
("application/x-amz-json-1.1" :: ByteString)])
instance ToJSON DetectDominantLanguage where
toJSON DetectDominantLanguage'{..}
= object (catMaybes [Just ("Text" .= _ddlText)])
instance ToPath DetectDominantLanguage where
toPath = const "/"
instance ToQuery DetectDominantLanguage where
toQuery = const mempty
data DetectDominantLanguageResponse = DetectDominantLanguageResponse'
{ _ddlrsLanguages :: !(Maybe [DominantLanguage])
, _ddlrsResponseStatus :: !Int
} deriving (Eq, Read, Show, Data, Typeable, Generic)
detectDominantLanguageResponse
:: Int
-> DetectDominantLanguageResponse
detectDominantLanguageResponse pResponseStatus_ =
DetectDominantLanguageResponse'
{_ddlrsLanguages = Nothing, _ddlrsResponseStatus = pResponseStatus_}
ddlrsLanguages :: Lens' DetectDominantLanguageResponse [DominantLanguage]
ddlrsLanguages = lens _ddlrsLanguages (\ s a -> s{_ddlrsLanguages = a}) . _Default . _Coerce
ddlrsResponseStatus :: Lens' DetectDominantLanguageResponse Int
ddlrsResponseStatus = lens _ddlrsResponseStatus (\ s a -> s{_ddlrsResponseStatus = a})
instance NFData DetectDominantLanguageResponse where