{-# 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.IoTAnalytics.BatchPutMessage
(
batchPutMessage
, BatchPutMessage
, bpmChannelName
, bpmMessages
, batchPutMessageResponse
, BatchPutMessageResponse
, bpmrsBatchPutMessageErrorEntries
, bpmrsResponseStatus
) where
import Network.AWS.IoTAnalytics.Types
import Network.AWS.IoTAnalytics.Types.Product
import Network.AWS.Lens
import Network.AWS.Prelude
import Network.AWS.Request
import Network.AWS.Response
data BatchPutMessage = BatchPutMessage'
{ _bpmChannelName :: !Text
, _bpmMessages :: ![Message]
} deriving (Eq, Read, Show, Data, Typeable, Generic)
batchPutMessage
:: Text
-> BatchPutMessage
batchPutMessage pChannelName_ =
BatchPutMessage' {_bpmChannelName = pChannelName_, _bpmMessages = mempty}
bpmChannelName :: Lens' BatchPutMessage Text
bpmChannelName = lens _bpmChannelName (\ s a -> s{_bpmChannelName = a})
bpmMessages :: Lens' BatchPutMessage [Message]
bpmMessages = lens _bpmMessages (\ s a -> s{_bpmMessages = a}) . _Coerce
instance AWSRequest BatchPutMessage where
type Rs BatchPutMessage = BatchPutMessageResponse
request = postJSON ioTAnalytics
response
= receiveJSON
(\ s h x ->
BatchPutMessageResponse' <$>
(x .?> "batchPutMessageErrorEntries" .!@ mempty) <*>
(pure (fromEnum s)))
instance Hashable BatchPutMessage where
instance NFData BatchPutMessage where
instance ToHeaders BatchPutMessage where
toHeaders = const mempty
instance ToJSON BatchPutMessage where
toJSON BatchPutMessage'{..}
= object
(catMaybes
[Just ("channelName" .= _bpmChannelName),
Just ("messages" .= _bpmMessages)])
instance ToPath BatchPutMessage where
toPath = const "/messages/batch"
instance ToQuery BatchPutMessage where
toQuery = const mempty
data BatchPutMessageResponse = BatchPutMessageResponse'
{ _bpmrsBatchPutMessageErrorEntries :: !(Maybe [BatchPutMessageErrorEntry])
, _bpmrsResponseStatus :: !Int
} deriving (Eq, Read, Show, Data, Typeable, Generic)
batchPutMessageResponse
:: Int
-> BatchPutMessageResponse
batchPutMessageResponse pResponseStatus_ =
BatchPutMessageResponse'
{ _bpmrsBatchPutMessageErrorEntries = Nothing
, _bpmrsResponseStatus = pResponseStatus_
}
bpmrsBatchPutMessageErrorEntries :: Lens' BatchPutMessageResponse [BatchPutMessageErrorEntry]
bpmrsBatchPutMessageErrorEntries = lens _bpmrsBatchPutMessageErrorEntries (\ s a -> s{_bpmrsBatchPutMessageErrorEntries = a}) . _Default . _Coerce
bpmrsResponseStatus :: Lens' BatchPutMessageResponse Int
bpmrsResponseStatus = lens _bpmrsResponseStatus (\ s a -> s{_bpmrsResponseStatus = a})
instance NFData BatchPutMessageResponse where