{-# 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.Glue.GetPartitions
(
getPartitions
, GetPartitions
, gpsCatalogId
, gpsNextToken
, gpsExpression
, gpsSegment
, gpsMaxResults
, gpsDatabaseName
, gpsTableName
, getPartitionsResponse
, GetPartitionsResponse
, gpsrsPartitions
, gpsrsNextToken
, gpsrsResponseStatus
) where
import Network.AWS.Glue.Types
import Network.AWS.Glue.Types.Product
import Network.AWS.Lens
import Network.AWS.Pager
import Network.AWS.Prelude
import Network.AWS.Request
import Network.AWS.Response
data GetPartitions = GetPartitions'
{ _gpsCatalogId :: !(Maybe Text)
, _gpsNextToken :: !(Maybe Text)
, _gpsExpression :: !(Maybe Text)
, _gpsSegment :: !(Maybe Segment)
, _gpsMaxResults :: !(Maybe Nat)
, _gpsDatabaseName :: !Text
, _gpsTableName :: !Text
} deriving (Eq, Read, Show, Data, Typeable, Generic)
getPartitions
:: Text
-> Text
-> GetPartitions
getPartitions pDatabaseName_ pTableName_ =
GetPartitions'
{ _gpsCatalogId = Nothing
, _gpsNextToken = Nothing
, _gpsExpression = Nothing
, _gpsSegment = Nothing
, _gpsMaxResults = Nothing
, _gpsDatabaseName = pDatabaseName_
, _gpsTableName = pTableName_
}
gpsCatalogId :: Lens' GetPartitions (Maybe Text)
gpsCatalogId = lens _gpsCatalogId (\ s a -> s{_gpsCatalogId = a})
gpsNextToken :: Lens' GetPartitions (Maybe Text)
gpsNextToken = lens _gpsNextToken (\ s a -> s{_gpsNextToken = a})
gpsExpression :: Lens' GetPartitions (Maybe Text)
gpsExpression = lens _gpsExpression (\ s a -> s{_gpsExpression = a})
gpsSegment :: Lens' GetPartitions (Maybe Segment)
gpsSegment = lens _gpsSegment (\ s a -> s{_gpsSegment = a})
gpsMaxResults :: Lens' GetPartitions (Maybe Natural)
gpsMaxResults = lens _gpsMaxResults (\ s a -> s{_gpsMaxResults = a}) . mapping _Nat
gpsDatabaseName :: Lens' GetPartitions Text
gpsDatabaseName = lens _gpsDatabaseName (\ s a -> s{_gpsDatabaseName = a})
gpsTableName :: Lens' GetPartitions Text
gpsTableName = lens _gpsTableName (\ s a -> s{_gpsTableName = a})
instance AWSPager GetPartitions where
page rq rs
| stop (rs ^. gpsrsNextToken) = Nothing
| stop (rs ^. gpsrsPartitions) = Nothing
| otherwise =
Just $ rq & gpsNextToken .~ rs ^. gpsrsNextToken
instance AWSRequest GetPartitions where
type Rs GetPartitions = GetPartitionsResponse
request = postJSON glue
response
= receiveJSON
(\ s h x ->
GetPartitionsResponse' <$>
(x .?> "Partitions" .!@ mempty) <*>
(x .?> "NextToken")
<*> (pure (fromEnum s)))
instance Hashable GetPartitions where
instance NFData GetPartitions where
instance ToHeaders GetPartitions where
toHeaders
= const
(mconcat
["X-Amz-Target" =#
("AWSGlue.GetPartitions" :: ByteString),
"Content-Type" =#
("application/x-amz-json-1.1" :: ByteString)])
instance ToJSON GetPartitions where
toJSON GetPartitions'{..}
= object
(catMaybes
[("CatalogId" .=) <$> _gpsCatalogId,
("NextToken" .=) <$> _gpsNextToken,
("Expression" .=) <$> _gpsExpression,
("Segment" .=) <$> _gpsSegment,
("MaxResults" .=) <$> _gpsMaxResults,
Just ("DatabaseName" .= _gpsDatabaseName),
Just ("TableName" .= _gpsTableName)])
instance ToPath GetPartitions where
toPath = const "/"
instance ToQuery GetPartitions where
toQuery = const mempty
data GetPartitionsResponse = GetPartitionsResponse'
{ _gpsrsPartitions :: !(Maybe [Partition])
, _gpsrsNextToken :: !(Maybe Text)
, _gpsrsResponseStatus :: !Int
} deriving (Eq, Read, Show, Data, Typeable, Generic)
getPartitionsResponse
:: Int
-> GetPartitionsResponse
getPartitionsResponse pResponseStatus_ =
GetPartitionsResponse'
{ _gpsrsPartitions = Nothing
, _gpsrsNextToken = Nothing
, _gpsrsResponseStatus = pResponseStatus_
}
gpsrsPartitions :: Lens' GetPartitionsResponse [Partition]
gpsrsPartitions = lens _gpsrsPartitions (\ s a -> s{_gpsrsPartitions = a}) . _Default . _Coerce
gpsrsNextToken :: Lens' GetPartitionsResponse (Maybe Text)
gpsrsNextToken = lens _gpsrsNextToken (\ s a -> s{_gpsrsNextToken = a})
gpsrsResponseStatus :: Lens' GetPartitionsResponse Int
gpsrsResponseStatus = lens _gpsrsResponseStatus (\ s a -> s{_gpsrsResponseStatus = a})
instance NFData GetPartitionsResponse where