{-# 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.IoTData.Publish
(
publish
, Publish
, pPayload
, pQos
, pTopic
, publishResponse
, PublishResponse
) where
import Network.AWS.IoTData.Types
import Network.AWS.IoTData.Types.Product
import Network.AWS.Lens
import Network.AWS.Prelude
import Network.AWS.Request
import Network.AWS.Response
data Publish = Publish'
{ _pPayload :: !(Maybe ByteString)
, _pQos :: !(Maybe Nat)
, _pTopic :: !Text
} deriving (Eq, Show, Data, Typeable, Generic)
publish
:: Text
-> Publish
publish pTopic_ =
Publish' {_pPayload = Nothing, _pQos = Nothing, _pTopic = pTopic_}
pPayload :: Lens' Publish (Maybe ByteString)
pPayload = lens _pPayload (\ s a -> s{_pPayload = a})
pQos :: Lens' Publish (Maybe Natural)
pQos = lens _pQos (\ s a -> s{_pQos = a}) . mapping _Nat
pTopic :: Lens' Publish Text
pTopic = lens _pTopic (\ s a -> s{_pTopic = a})
instance AWSRequest Publish where
type Rs Publish = PublishResponse
request = postBody ioTData
response = receiveNull PublishResponse'
instance Hashable Publish where
instance NFData Publish where
instance ToBody Publish where
toBody = toBody . _pPayload
instance ToHeaders Publish where
toHeaders = const mempty
instance ToPath Publish where
toPath Publish'{..}
= mconcat ["/topics/", toBS _pTopic]
instance ToQuery Publish where
toQuery Publish'{..} = mconcat ["qos" =: _pQos]
data PublishResponse =
PublishResponse'
deriving (Eq, Read, Show, Data, Typeable, Generic)
publishResponse
:: PublishResponse
publishResponse = PublishResponse'
instance NFData PublishResponse where