{-# 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.Transcribe.CreateVocabulary
(
createVocabulary
, CreateVocabulary
, cvVocabularyName
, cvLanguageCode
, cvPhrases
, createVocabularyResponse
, CreateVocabularyResponse
, cvrsFailureReason
, cvrsLanguageCode
, cvrsVocabularyName
, cvrsLastModifiedTime
, cvrsVocabularyState
, cvrsResponseStatus
) where
import Network.AWS.Lens
import Network.AWS.Prelude
import Network.AWS.Request
import Network.AWS.Response
import Network.AWS.Transcribe.Types
import Network.AWS.Transcribe.Types.Product
data CreateVocabulary = CreateVocabulary'
{ _cvVocabularyName :: !Text
, _cvLanguageCode :: !LanguageCode
, _cvPhrases :: ![Text]
} deriving (Eq, Read, Show, Data, Typeable, Generic)
createVocabulary
:: Text
-> LanguageCode
-> CreateVocabulary
createVocabulary pVocabularyName_ pLanguageCode_ =
CreateVocabulary'
{ _cvVocabularyName = pVocabularyName_
, _cvLanguageCode = pLanguageCode_
, _cvPhrases = mempty
}
cvVocabularyName :: Lens' CreateVocabulary Text
cvVocabularyName = lens _cvVocabularyName (\ s a -> s{_cvVocabularyName = a})
cvLanguageCode :: Lens' CreateVocabulary LanguageCode
cvLanguageCode = lens _cvLanguageCode (\ s a -> s{_cvLanguageCode = a})
cvPhrases :: Lens' CreateVocabulary [Text]
cvPhrases = lens _cvPhrases (\ s a -> s{_cvPhrases = a}) . _Coerce
instance AWSRequest CreateVocabulary where
type Rs CreateVocabulary = CreateVocabularyResponse
request = postJSON transcribe
response
= receiveJSON
(\ s h x ->
CreateVocabularyResponse' <$>
(x .?> "FailureReason") <*> (x .?> "LanguageCode")
<*> (x .?> "VocabularyName")
<*> (x .?> "LastModifiedTime")
<*> (x .?> "VocabularyState")
<*> (pure (fromEnum s)))
instance Hashable CreateVocabulary where
instance NFData CreateVocabulary where
instance ToHeaders CreateVocabulary where
toHeaders
= const
(mconcat
["X-Amz-Target" =#
("Transcribe.CreateVocabulary" :: ByteString),
"Content-Type" =#
("application/x-amz-json-1.1" :: ByteString)])
instance ToJSON CreateVocabulary where
toJSON CreateVocabulary'{..}
= object
(catMaybes
[Just ("VocabularyName" .= _cvVocabularyName),
Just ("LanguageCode" .= _cvLanguageCode),
Just ("Phrases" .= _cvPhrases)])
instance ToPath CreateVocabulary where
toPath = const "/"
instance ToQuery CreateVocabulary where
toQuery = const mempty
data CreateVocabularyResponse = CreateVocabularyResponse'
{ _cvrsFailureReason :: !(Maybe Text)
, _cvrsLanguageCode :: !(Maybe LanguageCode)
, _cvrsVocabularyName :: !(Maybe Text)
, _cvrsLastModifiedTime :: !(Maybe POSIX)
, _cvrsVocabularyState :: !(Maybe VocabularyState)
, _cvrsResponseStatus :: !Int
} deriving (Eq, Read, Show, Data, Typeable, Generic)
createVocabularyResponse
:: Int
-> CreateVocabularyResponse
createVocabularyResponse pResponseStatus_ =
CreateVocabularyResponse'
{ _cvrsFailureReason = Nothing
, _cvrsLanguageCode = Nothing
, _cvrsVocabularyName = Nothing
, _cvrsLastModifiedTime = Nothing
, _cvrsVocabularyState = Nothing
, _cvrsResponseStatus = pResponseStatus_
}
cvrsFailureReason :: Lens' CreateVocabularyResponse (Maybe Text)
cvrsFailureReason = lens _cvrsFailureReason (\ s a -> s{_cvrsFailureReason = a})
cvrsLanguageCode :: Lens' CreateVocabularyResponse (Maybe LanguageCode)
cvrsLanguageCode = lens _cvrsLanguageCode (\ s a -> s{_cvrsLanguageCode = a})
cvrsVocabularyName :: Lens' CreateVocabularyResponse (Maybe Text)
cvrsVocabularyName = lens _cvrsVocabularyName (\ s a -> s{_cvrsVocabularyName = a})
cvrsLastModifiedTime :: Lens' CreateVocabularyResponse (Maybe UTCTime)
cvrsLastModifiedTime = lens _cvrsLastModifiedTime (\ s a -> s{_cvrsLastModifiedTime = a}) . mapping _Time
cvrsVocabularyState :: Lens' CreateVocabularyResponse (Maybe VocabularyState)
cvrsVocabularyState = lens _cvrsVocabularyState (\ s a -> s{_cvrsVocabularyState = a})
cvrsResponseStatus :: Lens' CreateVocabularyResponse Int
cvrsResponseStatus = lens _cvrsResponseStatus (\ s a -> s{_cvrsResponseStatus = a})
instance NFData CreateVocabularyResponse where