{-# 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.DynamoDBStreams.GetRecords
(
getRecords
, GetRecords
, grLimit
, grShardIterator
, getRecordsResponse
, GetRecordsResponse
, grrsRecords
, grrsNextShardIterator
, grrsResponseStatus
) where
import Network.AWS.DynamoDBStreams.Types
import Network.AWS.DynamoDBStreams.Types.Product
import Network.AWS.Lens
import Network.AWS.Prelude
import Network.AWS.Request
import Network.AWS.Response
data GetRecords = GetRecords'
{ _grLimit :: !(Maybe Nat)
, _grShardIterator :: !Text
} deriving (Eq, Read, Show, Data, Typeable, Generic)
getRecords
:: Text
-> GetRecords
getRecords pShardIterator_ =
GetRecords' {_grLimit = Nothing, _grShardIterator = pShardIterator_}
grLimit :: Lens' GetRecords (Maybe Natural)
grLimit = lens _grLimit (\ s a -> s{_grLimit = a}) . mapping _Nat
grShardIterator :: Lens' GetRecords Text
grShardIterator = lens _grShardIterator (\ s a -> s{_grShardIterator = a})
instance AWSRequest GetRecords where
type Rs GetRecords = GetRecordsResponse
request = postJSON dynamoDBStreams
response
= receiveJSON
(\ s h x ->
GetRecordsResponse' <$>
(x .?> "Records" .!@ mempty) <*>
(x .?> "NextShardIterator")
<*> (pure (fromEnum s)))
instance Hashable GetRecords where
instance NFData GetRecords where
instance ToHeaders GetRecords where
toHeaders
= const
(mconcat
["X-Amz-Target" =#
("DynamoDBStreams_20120810.GetRecords" ::
ByteString),
"Content-Type" =#
("application/x-amz-json-1.0" :: ByteString)])
instance ToJSON GetRecords where
toJSON GetRecords'{..}
= object
(catMaybes
[("Limit" .=) <$> _grLimit,
Just ("ShardIterator" .= _grShardIterator)])
instance ToPath GetRecords where
toPath = const "/"
instance ToQuery GetRecords where
toQuery = const mempty
data GetRecordsResponse = GetRecordsResponse'
{ _grrsRecords :: !(Maybe [Record])
, _grrsNextShardIterator :: !(Maybe Text)
, _grrsResponseStatus :: !Int
} deriving (Eq, Read, Show, Data, Typeable, Generic)
getRecordsResponse
:: Int
-> GetRecordsResponse
getRecordsResponse pResponseStatus_ =
GetRecordsResponse'
{ _grrsRecords = Nothing
, _grrsNextShardIterator = Nothing
, _grrsResponseStatus = pResponseStatus_
}
grrsRecords :: Lens' GetRecordsResponse [Record]
grrsRecords = lens _grrsRecords (\ s a -> s{_grrsRecords = a}) . _Default . _Coerce
grrsNextShardIterator :: Lens' GetRecordsResponse (Maybe Text)
grrsNextShardIterator = lens _grrsNextShardIterator (\ s a -> s{_grrsNextShardIterator = a})
grrsResponseStatus :: Lens' GetRecordsResponse Int
grrsResponseStatus = lens _grrsResponseStatus (\ s a -> s{_grrsResponseStatus = a})
instance NFData GetRecordsResponse where