{-# 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.IoT.CreateThing
(
createThing
, CreateThing
, ctThingTypeName
, ctAttributePayload
, ctThingName
, createThingResponse
, CreateThingResponse
, ctrsThingARN
, ctrsThingName
, ctrsThingId
, 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'
{ _ctThingTypeName :: !(Maybe Text)
, _ctAttributePayload :: !(Maybe AttributePayload)
, _ctThingName :: !Text
} deriving (Eq, Read, Show, Data, Typeable, Generic)
createThing
:: Text
-> CreateThing
createThing pThingName_ =
CreateThing'
{ _ctThingTypeName = Nothing
, _ctAttributePayload = Nothing
, _ctThingName = pThingName_
}
ctThingTypeName :: Lens' CreateThing (Maybe Text)
ctThingTypeName = lens _ctThingTypeName (\ s a -> s{_ctThingTypeName = a})
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") <*>
(x .?> "thingId")
<*> (pure (fromEnum s)))
instance Hashable CreateThing where
instance NFData CreateThing where
instance ToHeaders CreateThing where
toHeaders = const mempty
instance ToJSON CreateThing where
toJSON CreateThing'{..}
= object
(catMaybes
[("thingTypeName" .=) <$> _ctThingTypeName,
("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)
, _ctrsThingId :: !(Maybe Text)
, _ctrsResponseStatus :: !Int
} deriving (Eq, Read, Show, Data, Typeable, Generic)
createThingResponse
:: Int
-> CreateThingResponse
createThingResponse pResponseStatus_ =
CreateThingResponse'
{ _ctrsThingARN = Nothing
, _ctrsThingName = Nothing
, _ctrsThingId = 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})
ctrsThingId :: Lens' CreateThingResponse (Maybe Text)
ctrsThingId = lens _ctrsThingId (\ s a -> s{_ctrsThingId = a})
ctrsResponseStatus :: Lens' CreateThingResponse Int
ctrsResponseStatus = lens _ctrsResponseStatus (\ s a -> s{_ctrsResponseStatus = a})
instance NFData CreateThingResponse where