{-# 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.CloudDirectory.BatchRead
(
batchRead
, BatchRead
, brConsistencyLevel
, brDirectoryARN
, brOperations
, batchReadResponse
, BatchReadResponse
, brrsResponses
, brrsResponseStatus
) where
import Network.AWS.CloudDirectory.Types
import Network.AWS.CloudDirectory.Types.Product
import Network.AWS.Lens
import Network.AWS.Prelude
import Network.AWS.Request
import Network.AWS.Response
data BatchRead = BatchRead'
{ _brConsistencyLevel :: !(Maybe ConsistencyLevel)
, _brDirectoryARN :: !Text
, _brOperations :: ![BatchReadOperation]
} deriving (Eq, Read, Show, Data, Typeable, Generic)
batchRead
:: Text
-> BatchRead
batchRead pDirectoryARN_ =
BatchRead'
{ _brConsistencyLevel = Nothing
, _brDirectoryARN = pDirectoryARN_
, _brOperations = mempty
}
brConsistencyLevel :: Lens' BatchRead (Maybe ConsistencyLevel)
brConsistencyLevel = lens _brConsistencyLevel (\ s a -> s{_brConsistencyLevel = a})
brDirectoryARN :: Lens' BatchRead Text
brDirectoryARN = lens _brDirectoryARN (\ s a -> s{_brDirectoryARN = a})
brOperations :: Lens' BatchRead [BatchReadOperation]
brOperations = lens _brOperations (\ s a -> s{_brOperations = a}) . _Coerce
instance AWSRequest BatchRead where
type Rs BatchRead = BatchReadResponse
request = postJSON cloudDirectory
response
= receiveJSON
(\ s h x ->
BatchReadResponse' <$>
(x .?> "Responses" .!@ mempty) <*>
(pure (fromEnum s)))
instance Hashable BatchRead where
instance NFData BatchRead where
instance ToHeaders BatchRead where
toHeaders BatchRead'{..}
= mconcat
["x-amz-consistency-level" =# _brConsistencyLevel,
"x-amz-data-partition" =# _brDirectoryARN]
instance ToJSON BatchRead where
toJSON BatchRead'{..}
= object
(catMaybes [Just ("Operations" .= _brOperations)])
instance ToPath BatchRead where
toPath
= const "/amazonclouddirectory/2017-01-11/batchread"
instance ToQuery BatchRead where
toQuery = const mempty
data BatchReadResponse = BatchReadResponse'
{ _brrsResponses :: !(Maybe [BatchReadOperationResponse])
, _brrsResponseStatus :: !Int
} deriving (Eq, Read, Show, Data, Typeable, Generic)
batchReadResponse
:: Int
-> BatchReadResponse
batchReadResponse pResponseStatus_ =
BatchReadResponse'
{_brrsResponses = Nothing, _brrsResponseStatus = pResponseStatus_}
brrsResponses :: Lens' BatchReadResponse [BatchReadOperationResponse]
brrsResponses = lens _brrsResponses (\ s a -> s{_brrsResponses = a}) . _Default . _Coerce
brrsResponseStatus :: Lens' BatchReadResponse Int
brrsResponseStatus = lens _brrsResponseStatus (\ s a -> s{_brrsResponseStatus = a})
instance NFData BatchReadResponse where