{-# 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.ListNamedQueries
(
listNamedQueries
, ListNamedQueries
, lnqNextToken
, lnqMaxResults
, listNamedQueriesResponse
, ListNamedQueriesResponse
, lnqrsNextToken
, lnqrsNamedQueryIds
, lnqrsResponseStatus
) where
import Network.AWS.Athena.Types
import Network.AWS.Athena.Types.Product
import Network.AWS.Lens
import Network.AWS.Pager
import Network.AWS.Prelude
import Network.AWS.Request
import Network.AWS.Response
data ListNamedQueries = ListNamedQueries'
{ _lnqNextToken :: !(Maybe Text)
, _lnqMaxResults :: !(Maybe Nat)
} deriving (Eq, Read, Show, Data, Typeable, Generic)
listNamedQueries
:: ListNamedQueries
listNamedQueries =
ListNamedQueries' {_lnqNextToken = Nothing, _lnqMaxResults = Nothing}
lnqNextToken :: Lens' ListNamedQueries (Maybe Text)
lnqNextToken = lens _lnqNextToken (\ s a -> s{_lnqNextToken = a})
lnqMaxResults :: Lens' ListNamedQueries (Maybe Natural)
lnqMaxResults = lens _lnqMaxResults (\ s a -> s{_lnqMaxResults = a}) . mapping _Nat
instance AWSPager ListNamedQueries where
page rq rs
| stop (rs ^. lnqrsNextToken) = Nothing
| stop (rs ^. lnqrsNamedQueryIds) = Nothing
| otherwise =
Just $ rq & lnqNextToken .~ rs ^. lnqrsNextToken
instance AWSRequest ListNamedQueries where
type Rs ListNamedQueries = ListNamedQueriesResponse
request = postJSON athena
response
= receiveJSON
(\ s h x ->
ListNamedQueriesResponse' <$>
(x .?> "NextToken") <*> (x .?> "NamedQueryIds") <*>
(pure (fromEnum s)))
instance Hashable ListNamedQueries where
instance NFData ListNamedQueries where
instance ToHeaders ListNamedQueries where
toHeaders
= const
(mconcat
["X-Amz-Target" =#
("AmazonAthena.ListNamedQueries" :: ByteString),
"Content-Type" =#
("application/x-amz-json-1.1" :: ByteString)])
instance ToJSON ListNamedQueries where
toJSON ListNamedQueries'{..}
= object
(catMaybes
[("NextToken" .=) <$> _lnqNextToken,
("MaxResults" .=) <$> _lnqMaxResults])
instance ToPath ListNamedQueries where
toPath = const "/"
instance ToQuery ListNamedQueries where
toQuery = const mempty
data ListNamedQueriesResponse = ListNamedQueriesResponse'
{ _lnqrsNextToken :: !(Maybe Text)
, _lnqrsNamedQueryIds :: !(Maybe (List1 Text))
, _lnqrsResponseStatus :: !Int
} deriving (Eq, Read, Show, Data, Typeable, Generic)
listNamedQueriesResponse
:: Int
-> ListNamedQueriesResponse
listNamedQueriesResponse pResponseStatus_ =
ListNamedQueriesResponse'
{ _lnqrsNextToken = Nothing
, _lnqrsNamedQueryIds = Nothing
, _lnqrsResponseStatus = pResponseStatus_
}
lnqrsNextToken :: Lens' ListNamedQueriesResponse (Maybe Text)
lnqrsNextToken = lens _lnqrsNextToken (\ s a -> s{_lnqrsNextToken = a})
lnqrsNamedQueryIds :: Lens' ListNamedQueriesResponse (Maybe (NonEmpty Text))
lnqrsNamedQueryIds = lens _lnqrsNamedQueryIds (\ s a -> s{_lnqrsNamedQueryIds = a}) . mapping _List1
lnqrsResponseStatus :: Lens' ListNamedQueriesResponse Int
lnqrsResponseStatus = lens _lnqrsResponseStatus (\ s a -> s{_lnqrsResponseStatus = a})
instance NFData ListNamedQueriesResponse where