{-# 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.GetPartition
(
getPartition
, GetPartition
, gpCatalogId
, gpDatabaseName
, gpTableName
, gpPartitionValues
, getPartitionResponse
, GetPartitionResponse
, gprsPartition
, gprsResponseStatus
) 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 GetPartition = GetPartition'
{ _gpCatalogId :: !(Maybe Text)
, _gpDatabaseName :: !Text
, _gpTableName :: !Text
, _gpPartitionValues :: ![Text]
} deriving (Eq, Read, Show, Data, Typeable, Generic)
getPartition
:: Text
-> Text
-> GetPartition
getPartition pDatabaseName_ pTableName_ =
GetPartition'
{ _gpCatalogId = Nothing
, _gpDatabaseName = pDatabaseName_
, _gpTableName = pTableName_
, _gpPartitionValues = mempty
}
gpCatalogId :: Lens' GetPartition (Maybe Text)
gpCatalogId = lens _gpCatalogId (\ s a -> s{_gpCatalogId = a})
gpDatabaseName :: Lens' GetPartition Text
gpDatabaseName = lens _gpDatabaseName (\ s a -> s{_gpDatabaseName = a})
gpTableName :: Lens' GetPartition Text
gpTableName = lens _gpTableName (\ s a -> s{_gpTableName = a})
gpPartitionValues :: Lens' GetPartition [Text]
gpPartitionValues = lens _gpPartitionValues (\ s a -> s{_gpPartitionValues = a}) . _Coerce
instance AWSRequest GetPartition where
type Rs GetPartition = GetPartitionResponse
request = postJSON glue
response
= receiveJSON
(\ s h x ->
GetPartitionResponse' <$>
(x .?> "Partition") <*> (pure (fromEnum s)))
instance Hashable GetPartition where
instance NFData GetPartition where
instance ToHeaders GetPartition where
toHeaders
= const
(mconcat
["X-Amz-Target" =#
("AWSGlue.GetPartition" :: ByteString),
"Content-Type" =#
("application/x-amz-json-1.1" :: ByteString)])
instance ToJSON GetPartition where
toJSON GetPartition'{..}
= object
(catMaybes
[("CatalogId" .=) <$> _gpCatalogId,
Just ("DatabaseName" .= _gpDatabaseName),
Just ("TableName" .= _gpTableName),
Just ("PartitionValues" .= _gpPartitionValues)])
instance ToPath GetPartition where
toPath = const "/"
instance ToQuery GetPartition where
toQuery = const mempty
data GetPartitionResponse = GetPartitionResponse'
{ _gprsPartition :: !(Maybe Partition)
, _gprsResponseStatus :: !Int
} deriving (Eq, Read, Show, Data, Typeable, Generic)
getPartitionResponse
:: Int
-> GetPartitionResponse
getPartitionResponse pResponseStatus_ =
GetPartitionResponse'
{_gprsPartition = Nothing, _gprsResponseStatus = pResponseStatus_}
gprsPartition :: Lens' GetPartitionResponse (Maybe Partition)
gprsPartition = lens _gprsPartition (\ s a -> s{_gprsPartition = a})
gprsResponseStatus :: Lens' GetPartitionResponse Int
gprsResponseStatus = lens _gprsResponseStatus (\ s a -> s{_gprsResponseStatus = a})
instance NFData GetPartitionResponse where