module Network.AWS.IoT.CreateThing
(
createThing
, CreateThing
, ctAttributePayload
, ctThingName
, createThingResponse
, CreateThingResponse
, ctrsThingARN
, ctrsThingName
, ctrsResponseStatus
) where
import Network.AWS.IoT.Types
import Network.AWS.IoT.Types.Product
import Network.AWS.Lens
import Network.AWS.Prelude
import Network.AWS.Request
import Network.AWS.Response
data CreateThing = CreateThing'
{ _ctAttributePayload :: !(Maybe AttributePayload)
, _ctThingName :: !Text
} deriving (Eq,Read,Show,Data,Typeable,Generic)
createThing
:: Text
-> CreateThing
createThing pThingName_ =
CreateThing'
{ _ctAttributePayload = Nothing
, _ctThingName = pThingName_
}
ctAttributePayload :: Lens' CreateThing (Maybe AttributePayload)
ctAttributePayload = lens _ctAttributePayload (\ s a -> s{_ctAttributePayload = a});
ctThingName :: Lens' CreateThing Text
ctThingName = lens _ctThingName (\ s a -> s{_ctThingName = a});
instance AWSRequest CreateThing where
type Rs CreateThing = CreateThingResponse
request = postJSON ioT
response
= receiveJSON
(\ s h x ->
CreateThingResponse' <$>
(x .?> "thingArn") <*> (x .?> "thingName") <*>
(pure (fromEnum s)))
instance Hashable CreateThing
instance NFData CreateThing
instance ToHeaders CreateThing where
toHeaders = const mempty
instance ToJSON CreateThing where
toJSON CreateThing'{..}
= object
(catMaybes
[("attributePayload" .=) <$> _ctAttributePayload])
instance ToPath CreateThing where
toPath CreateThing'{..}
= mconcat ["/things/", toBS _ctThingName]
instance ToQuery CreateThing where
toQuery = const mempty
data CreateThingResponse = CreateThingResponse'
{ _ctrsThingARN :: !(Maybe Text)
, _ctrsThingName :: !(Maybe Text)
, _ctrsResponseStatus :: !Int
} deriving (Eq,Read,Show,Data,Typeable,Generic)
createThingResponse
:: Int
-> CreateThingResponse
createThingResponse pResponseStatus_ =
CreateThingResponse'
{ _ctrsThingARN = Nothing
, _ctrsThingName = Nothing
, _ctrsResponseStatus = pResponseStatus_
}
ctrsThingARN :: Lens' CreateThingResponse (Maybe Text)
ctrsThingARN = lens _ctrsThingARN (\ s a -> s{_ctrsThingARN = a});
ctrsThingName :: Lens' CreateThingResponse (Maybe Text)
ctrsThingName = lens _ctrsThingName (\ s a -> s{_ctrsThingName = a});
ctrsResponseStatus :: Lens' CreateThingResponse Int
ctrsResponseStatus = lens _ctrsResponseStatus (\ s a -> s{_ctrsResponseStatus = a});
instance NFData CreateThingResponse