{-# 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.CreateThingGroup
(
createThingGroup
, CreateThingGroup
, ctgParentGroupName
, ctgThingGroupProperties
, ctgThingGroupName
, createThingGroupResponse
, CreateThingGroupResponse
, ctgrsThingGroupARN
, ctgrsThingGroupId
, ctgrsThingGroupName
, ctgrsResponseStatus
) 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 CreateThingGroup = CreateThingGroup'
{ _ctgParentGroupName :: !(Maybe Text)
, _ctgThingGroupProperties :: !(Maybe ThingGroupProperties)
, _ctgThingGroupName :: !Text
} deriving (Eq, Read, Show, Data, Typeable, Generic)
createThingGroup
:: Text
-> CreateThingGroup
createThingGroup pThingGroupName_ =
CreateThingGroup'
{ _ctgParentGroupName = Nothing
, _ctgThingGroupProperties = Nothing
, _ctgThingGroupName = pThingGroupName_
}
ctgParentGroupName :: Lens' CreateThingGroup (Maybe Text)
ctgParentGroupName = lens _ctgParentGroupName (\ s a -> s{_ctgParentGroupName = a})
ctgThingGroupProperties :: Lens' CreateThingGroup (Maybe ThingGroupProperties)
ctgThingGroupProperties = lens _ctgThingGroupProperties (\ s a -> s{_ctgThingGroupProperties = a})
ctgThingGroupName :: Lens' CreateThingGroup Text
ctgThingGroupName = lens _ctgThingGroupName (\ s a -> s{_ctgThingGroupName = a})
instance AWSRequest CreateThingGroup where
type Rs CreateThingGroup = CreateThingGroupResponse
request = postJSON ioT
response
= receiveJSON
(\ s h x ->
CreateThingGroupResponse' <$>
(x .?> "thingGroupArn") <*> (x .?> "thingGroupId")
<*> (x .?> "thingGroupName")
<*> (pure (fromEnum s)))
instance Hashable CreateThingGroup where
instance NFData CreateThingGroup where
instance ToHeaders CreateThingGroup where
toHeaders = const mempty
instance ToJSON CreateThingGroup where
toJSON CreateThingGroup'{..}
= object
(catMaybes
[("parentGroupName" .=) <$> _ctgParentGroupName,
("thingGroupProperties" .=) <$>
_ctgThingGroupProperties])
instance ToPath CreateThingGroup where
toPath CreateThingGroup'{..}
= mconcat ["/thing-groups/", toBS _ctgThingGroupName]
instance ToQuery CreateThingGroup where
toQuery = const mempty
data CreateThingGroupResponse = CreateThingGroupResponse'
{ _ctgrsThingGroupARN :: !(Maybe Text)
, _ctgrsThingGroupId :: !(Maybe Text)
, _ctgrsThingGroupName :: !(Maybe Text)
, _ctgrsResponseStatus :: !Int
} deriving (Eq, Read, Show, Data, Typeable, Generic)
createThingGroupResponse
:: Int
-> CreateThingGroupResponse
createThingGroupResponse pResponseStatus_ =
CreateThingGroupResponse'
{ _ctgrsThingGroupARN = Nothing
, _ctgrsThingGroupId = Nothing
, _ctgrsThingGroupName = Nothing
, _ctgrsResponseStatus = pResponseStatus_
}
ctgrsThingGroupARN :: Lens' CreateThingGroupResponse (Maybe Text)
ctgrsThingGroupARN = lens _ctgrsThingGroupARN (\ s a -> s{_ctgrsThingGroupARN = a})
ctgrsThingGroupId :: Lens' CreateThingGroupResponse (Maybe Text)
ctgrsThingGroupId = lens _ctgrsThingGroupId (\ s a -> s{_ctgrsThingGroupId = a})
ctgrsThingGroupName :: Lens' CreateThingGroupResponse (Maybe Text)
ctgrsThingGroupName = lens _ctgrsThingGroupName (\ s a -> s{_ctgrsThingGroupName = a})
ctgrsResponseStatus :: Lens' CreateThingGroupResponse Int
ctgrsResponseStatus = lens _ctgrsResponseStatus (\ s a -> s{_ctgrsResponseStatus = a})
instance NFData CreateThingGroupResponse where