{-# 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.Athena.CreateNamedQuery
(
createNamedQuery
, CreateNamedQuery
, cnqClientRequestToken
, cnqDescription
, cnqName
, cnqDatabase
, cnqQueryString
, createNamedQueryResponse
, CreateNamedQueryResponse
, cnqrsNamedQueryId
, cnqrsResponseStatus
) where
import Network.AWS.Athena.Types
import Network.AWS.Athena.Types.Product
import Network.AWS.Lens
import Network.AWS.Prelude
import Network.AWS.Request
import Network.AWS.Response
data CreateNamedQuery = CreateNamedQuery'
{ _cnqClientRequestToken :: !(Maybe Text)
, _cnqDescription :: !(Maybe Text)
, _cnqName :: !Text
, _cnqDatabase :: !Text
, _cnqQueryString :: !Text
} deriving (Eq, Read, Show, Data, Typeable, Generic)
createNamedQuery
:: Text
-> Text
-> Text
-> CreateNamedQuery
createNamedQuery pName_ pDatabase_ pQueryString_ =
CreateNamedQuery'
{ _cnqClientRequestToken = Nothing
, _cnqDescription = Nothing
, _cnqName = pName_
, _cnqDatabase = pDatabase_
, _cnqQueryString = pQueryString_
}
cnqClientRequestToken :: Lens' CreateNamedQuery (Maybe Text)
cnqClientRequestToken = lens _cnqClientRequestToken (\ s a -> s{_cnqClientRequestToken = a})
cnqDescription :: Lens' CreateNamedQuery (Maybe Text)
cnqDescription = lens _cnqDescription (\ s a -> s{_cnqDescription = a})
cnqName :: Lens' CreateNamedQuery Text
cnqName = lens _cnqName (\ s a -> s{_cnqName = a})
cnqDatabase :: Lens' CreateNamedQuery Text
cnqDatabase = lens _cnqDatabase (\ s a -> s{_cnqDatabase = a})
cnqQueryString :: Lens' CreateNamedQuery Text
cnqQueryString = lens _cnqQueryString (\ s a -> s{_cnqQueryString = a})
instance AWSRequest CreateNamedQuery where
type Rs CreateNamedQuery = CreateNamedQueryResponse
request = postJSON athena
response
= receiveJSON
(\ s h x ->
CreateNamedQueryResponse' <$>
(x .?> "NamedQueryId") <*> (pure (fromEnum s)))
instance Hashable CreateNamedQuery where
instance NFData CreateNamedQuery where
instance ToHeaders CreateNamedQuery where
toHeaders
= const
(mconcat
["X-Amz-Target" =#
("AmazonAthena.CreateNamedQuery" :: ByteString),
"Content-Type" =#
("application/x-amz-json-1.1" :: ByteString)])
instance ToJSON CreateNamedQuery where
toJSON CreateNamedQuery'{..}
= object
(catMaybes
[("ClientRequestToken" .=) <$>
_cnqClientRequestToken,
("Description" .=) <$> _cnqDescription,
Just ("Name" .= _cnqName),
Just ("Database" .= _cnqDatabase),
Just ("QueryString" .= _cnqQueryString)])
instance ToPath CreateNamedQuery where
toPath = const "/"
instance ToQuery CreateNamedQuery where
toQuery = const mempty
data CreateNamedQueryResponse = CreateNamedQueryResponse'
{ _cnqrsNamedQueryId :: !(Maybe Text)
, _cnqrsResponseStatus :: !Int
} deriving (Eq, Read, Show, Data, Typeable, Generic)
createNamedQueryResponse
:: Int
-> CreateNamedQueryResponse
createNamedQueryResponse pResponseStatus_ =
CreateNamedQueryResponse'
{_cnqrsNamedQueryId = Nothing, _cnqrsResponseStatus = pResponseStatus_}
cnqrsNamedQueryId :: Lens' CreateNamedQueryResponse (Maybe Text)
cnqrsNamedQueryId = lens _cnqrsNamedQueryId (\ s a -> s{_cnqrsNamedQueryId = a})
cnqrsResponseStatus :: Lens' CreateNamedQueryResponse Int
cnqrsResponseStatus = lens _cnqrsResponseStatus (\ s a -> s{_cnqrsResponseStatus = a})
instance NFData CreateNamedQueryResponse where