{-# 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.ListThingGroupsForThing
(
listThingGroupsForThing
, ListThingGroupsForThing
, ltgftNextToken
, ltgftMaxResults
, ltgftThingName
, listThingGroupsForThingResponse
, ListThingGroupsForThingResponse
, ltgftrsThingGroups
, ltgftrsNextToken
, ltgftrsResponseStatus
) 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 ListThingGroupsForThing = ListThingGroupsForThing'
{ _ltgftNextToken :: !(Maybe Text)
, _ltgftMaxResults :: !(Maybe Nat)
, _ltgftThingName :: !Text
} deriving (Eq, Read, Show, Data, Typeable, Generic)
listThingGroupsForThing
:: Text
-> ListThingGroupsForThing
listThingGroupsForThing pThingName_ =
ListThingGroupsForThing'
{ _ltgftNextToken = Nothing
, _ltgftMaxResults = Nothing
, _ltgftThingName = pThingName_
}
ltgftNextToken :: Lens' ListThingGroupsForThing (Maybe Text)
ltgftNextToken = lens _ltgftNextToken (\ s a -> s{_ltgftNextToken = a})
ltgftMaxResults :: Lens' ListThingGroupsForThing (Maybe Natural)
ltgftMaxResults = lens _ltgftMaxResults (\ s a -> s{_ltgftMaxResults = a}) . mapping _Nat
ltgftThingName :: Lens' ListThingGroupsForThing Text
ltgftThingName = lens _ltgftThingName (\ s a -> s{_ltgftThingName = a})
instance AWSRequest ListThingGroupsForThing where
type Rs ListThingGroupsForThing =
ListThingGroupsForThingResponse
request = get ioT
response
= receiveJSON
(\ s h x ->
ListThingGroupsForThingResponse' <$>
(x .?> "thingGroups" .!@ mempty) <*>
(x .?> "nextToken")
<*> (pure (fromEnum s)))
instance Hashable ListThingGroupsForThing where
instance NFData ListThingGroupsForThing where
instance ToHeaders ListThingGroupsForThing where
toHeaders = const mempty
instance ToPath ListThingGroupsForThing where
toPath ListThingGroupsForThing'{..}
= mconcat
["/things/", toBS _ltgftThingName, "/thing-groups"]
instance ToQuery ListThingGroupsForThing where
toQuery ListThingGroupsForThing'{..}
= mconcat
["nextToken" =: _ltgftNextToken,
"maxResults" =: _ltgftMaxResults]
data ListThingGroupsForThingResponse = ListThingGroupsForThingResponse'
{ _ltgftrsThingGroups :: !(Maybe [GroupNameAndARN])
, _ltgftrsNextToken :: !(Maybe Text)
, _ltgftrsResponseStatus :: !Int
} deriving (Eq, Read, Show, Data, Typeable, Generic)
listThingGroupsForThingResponse
:: Int
-> ListThingGroupsForThingResponse
listThingGroupsForThingResponse pResponseStatus_ =
ListThingGroupsForThingResponse'
{ _ltgftrsThingGroups = Nothing
, _ltgftrsNextToken = Nothing
, _ltgftrsResponseStatus = pResponseStatus_
}
ltgftrsThingGroups :: Lens' ListThingGroupsForThingResponse [GroupNameAndARN]
ltgftrsThingGroups = lens _ltgftrsThingGroups (\ s a -> s{_ltgftrsThingGroups = a}) . _Default . _Coerce
ltgftrsNextToken :: Lens' ListThingGroupsForThingResponse (Maybe Text)
ltgftrsNextToken = lens _ltgftrsNextToken (\ s a -> s{_ltgftrsNextToken = a})
ltgftrsResponseStatus :: Lens' ListThingGroupsForThingResponse Int
ltgftrsResponseStatus = lens _ltgftrsResponseStatus (\ s a -> s{_ltgftrsResponseStatus = a})
instance NFData ListThingGroupsForThingResponse where