{-# 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.BatchGetPartition
(
batchGetPartition
, BatchGetPartition
, bgpCatalogId
, bgpDatabaseName
, bgpTableName
, bgpPartitionsToGet
, batchGetPartitionResponse
, BatchGetPartitionResponse
, bgprsUnprocessedKeys
, bgprsPartitions
, bgprsResponseStatus
) where
import Network.AWS.Glue.Types
import Network.AWS.Glue.Types.Product
import Network.AWS.Lens
import Network.AWS.Prelude
import Network.AWS.Request
import Network.AWS.Response
data BatchGetPartition = BatchGetPartition'
{ _bgpCatalogId :: !(Maybe Text)
, _bgpDatabaseName :: !Text
, _bgpTableName :: !Text
, _bgpPartitionsToGet :: ![PartitionValueList]
} deriving (Eq, Read, Show, Data, Typeable, Generic)
batchGetPartition
:: Text
-> Text
-> BatchGetPartition
batchGetPartition pDatabaseName_ pTableName_ =
BatchGetPartition'
{ _bgpCatalogId = Nothing
, _bgpDatabaseName = pDatabaseName_
, _bgpTableName = pTableName_
, _bgpPartitionsToGet = mempty
}
bgpCatalogId :: Lens' BatchGetPartition (Maybe Text)
bgpCatalogId = lens _bgpCatalogId (\ s a -> s{_bgpCatalogId = a})
bgpDatabaseName :: Lens' BatchGetPartition Text
bgpDatabaseName = lens _bgpDatabaseName (\ s a -> s{_bgpDatabaseName = a})
bgpTableName :: Lens' BatchGetPartition Text
bgpTableName = lens _bgpTableName (\ s a -> s{_bgpTableName = a})
bgpPartitionsToGet :: Lens' BatchGetPartition [PartitionValueList]
bgpPartitionsToGet = lens _bgpPartitionsToGet (\ s a -> s{_bgpPartitionsToGet = a}) . _Coerce
instance AWSRequest BatchGetPartition where
type Rs BatchGetPartition = BatchGetPartitionResponse
request = postJSON glue
response
= receiveJSON
(\ s h x ->
BatchGetPartitionResponse' <$>
(x .?> "UnprocessedKeys" .!@ mempty) <*>
(x .?> "Partitions" .!@ mempty)
<*> (pure (fromEnum s)))
instance Hashable BatchGetPartition where
instance NFData BatchGetPartition where
instance ToHeaders BatchGetPartition where
toHeaders
= const
(mconcat
["X-Amz-Target" =#
("AWSGlue.BatchGetPartition" :: ByteString),
"Content-Type" =#
("application/x-amz-json-1.1" :: ByteString)])
instance ToJSON BatchGetPartition where
toJSON BatchGetPartition'{..}
= object
(catMaybes
[("CatalogId" .=) <$> _bgpCatalogId,
Just ("DatabaseName" .= _bgpDatabaseName),
Just ("TableName" .= _bgpTableName),
Just ("PartitionsToGet" .= _bgpPartitionsToGet)])
instance ToPath BatchGetPartition where
toPath = const "/"
instance ToQuery BatchGetPartition where
toQuery = const mempty
data BatchGetPartitionResponse = BatchGetPartitionResponse'
{ _bgprsUnprocessedKeys :: !(Maybe [PartitionValueList])
, _bgprsPartitions :: !(Maybe [Partition])
, _bgprsResponseStatus :: !Int
} deriving (Eq, Read, Show, Data, Typeable, Generic)
batchGetPartitionResponse
:: Int
-> BatchGetPartitionResponse
batchGetPartitionResponse pResponseStatus_ =
BatchGetPartitionResponse'
{ _bgprsUnprocessedKeys = Nothing
, _bgprsPartitions = Nothing
, _bgprsResponseStatus = pResponseStatus_
}
bgprsUnprocessedKeys :: Lens' BatchGetPartitionResponse [PartitionValueList]
bgprsUnprocessedKeys = lens _bgprsUnprocessedKeys (\ s a -> s{_bgprsUnprocessedKeys = a}) . _Default . _Coerce
bgprsPartitions :: Lens' BatchGetPartitionResponse [Partition]
bgprsPartitions = lens _bgprsPartitions (\ s a -> s{_bgprsPartitions = a}) . _Default . _Coerce
bgprsResponseStatus :: Lens' BatchGetPartitionResponse Int
bgprsResponseStatus = lens _bgprsResponseStatus (\ s a -> s{_bgprsResponseStatus = a})
instance NFData BatchGetPartitionResponse where