{-# 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.StartQueryExecution
(
startQueryExecution
, StartQueryExecution
, sqeQueryExecutionContext
, sqeClientRequestToken
, sqeQueryString
, sqeResultConfiguration
, startQueryExecutionResponse
, StartQueryExecutionResponse
, sqersQueryExecutionId
, sqersResponseStatus
) 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 StartQueryExecution = StartQueryExecution'
{ _sqeQueryExecutionContext :: !(Maybe QueryExecutionContext)
, _sqeClientRequestToken :: !(Maybe Text)
, _sqeQueryString :: !Text
, _sqeResultConfiguration :: !ResultConfiguration
} deriving (Eq, Read, Show, Data, Typeable, Generic)
startQueryExecution
:: Text
-> ResultConfiguration
-> StartQueryExecution
startQueryExecution pQueryString_ pResultConfiguration_ =
StartQueryExecution'
{ _sqeQueryExecutionContext = Nothing
, _sqeClientRequestToken = Nothing
, _sqeQueryString = pQueryString_
, _sqeResultConfiguration = pResultConfiguration_
}
sqeQueryExecutionContext :: Lens' StartQueryExecution (Maybe QueryExecutionContext)
sqeQueryExecutionContext = lens _sqeQueryExecutionContext (\ s a -> s{_sqeQueryExecutionContext = a})
sqeClientRequestToken :: Lens' StartQueryExecution (Maybe Text)
sqeClientRequestToken = lens _sqeClientRequestToken (\ s a -> s{_sqeClientRequestToken = a})
sqeQueryString :: Lens' StartQueryExecution Text
sqeQueryString = lens _sqeQueryString (\ s a -> s{_sqeQueryString = a})
sqeResultConfiguration :: Lens' StartQueryExecution ResultConfiguration
sqeResultConfiguration = lens _sqeResultConfiguration (\ s a -> s{_sqeResultConfiguration = a})
instance AWSRequest StartQueryExecution where
type Rs StartQueryExecution =
StartQueryExecutionResponse
request = postJSON athena
response
= receiveJSON
(\ s h x ->
StartQueryExecutionResponse' <$>
(x .?> "QueryExecutionId") <*> (pure (fromEnum s)))
instance Hashable StartQueryExecution where
instance NFData StartQueryExecution where
instance ToHeaders StartQueryExecution where
toHeaders
= const
(mconcat
["X-Amz-Target" =#
("AmazonAthena.StartQueryExecution" :: ByteString),
"Content-Type" =#
("application/x-amz-json-1.1" :: ByteString)])
instance ToJSON StartQueryExecution where
toJSON StartQueryExecution'{..}
= object
(catMaybes
[("QueryExecutionContext" .=) <$>
_sqeQueryExecutionContext,
("ClientRequestToken" .=) <$> _sqeClientRequestToken,
Just ("QueryString" .= _sqeQueryString),
Just
("ResultConfiguration" .= _sqeResultConfiguration)])
instance ToPath StartQueryExecution where
toPath = const "/"
instance ToQuery StartQueryExecution where
toQuery = const mempty
data StartQueryExecutionResponse = StartQueryExecutionResponse'
{ _sqersQueryExecutionId :: !(Maybe Text)
, _sqersResponseStatus :: !Int
} deriving (Eq, Read, Show, Data, Typeable, Generic)
startQueryExecutionResponse
:: Int
-> StartQueryExecutionResponse
startQueryExecutionResponse pResponseStatus_ =
StartQueryExecutionResponse'
{_sqersQueryExecutionId = Nothing, _sqersResponseStatus = pResponseStatus_}
sqersQueryExecutionId :: Lens' StartQueryExecutionResponse (Maybe Text)
sqersQueryExecutionId = lens _sqersQueryExecutionId (\ s a -> s{_sqersQueryExecutionId = a})
sqersResponseStatus :: Lens' StartQueryExecutionResponse Int
sqersResponseStatus = lens _sqersResponseStatus (\ s a -> s{_sqersResponseStatus = a})
instance NFData StartQueryExecutionResponse where