module Network.AWS.IAM.GetGroup
(
getGroup
, GetGroup
, ggMarker
, ggMaxItems
, ggGroupName
, getGroupResponse
, GetGroupResponse
, ggrsMarker
, ggrsIsTruncated
, ggrsResponseStatus
, ggrsGroup
, ggrsUsers
) where
import Network.AWS.IAM.Types
import Network.AWS.IAM.Types.Product
import Network.AWS.Pager
import Network.AWS.Prelude
import Network.AWS.Request
import Network.AWS.Response
data GetGroup = GetGroup'
{ _ggMarker :: !(Maybe Text)
, _ggMaxItems :: !(Maybe Nat)
, _ggGroupName :: !Text
} deriving (Eq,Read,Show,Data,Typeable,Generic)
getGroup
:: Text
-> GetGroup
getGroup pGroupName_ =
GetGroup'
{ _ggMarker = Nothing
, _ggMaxItems = Nothing
, _ggGroupName = pGroupName_
}
ggMarker :: Lens' GetGroup (Maybe Text)
ggMarker = lens _ggMarker (\ s a -> s{_ggMarker = a});
ggMaxItems :: Lens' GetGroup (Maybe Natural)
ggMaxItems = lens _ggMaxItems (\ s a -> s{_ggMaxItems = a}) . mapping _Nat;
ggGroupName :: Lens' GetGroup Text
ggGroupName = lens _ggGroupName (\ s a -> s{_ggGroupName = a});
instance AWSPager GetGroup where
page rq rs
| stop (rs ^. ggrsIsTruncated) = Nothing
| isNothing (rs ^. ggrsMarker) = Nothing
| otherwise =
Just $ rq & ggMarker .~ rs ^. ggrsMarker
instance AWSRequest GetGroup where
type Rs GetGroup = GetGroupResponse
request = postQuery iAM
response
= receiveXMLWrapper "GetGroupResult"
(\ s h x ->
GetGroupResponse' <$>
(x .@? "Marker") <*> (x .@? "IsTruncated") <*>
(pure (fromEnum s))
<*> (x .@ "Group")
<*>
(x .@? "Users" .!@ mempty >>= parseXMLList "member"))
instance ToHeaders GetGroup where
toHeaders = const mempty
instance ToPath GetGroup where
toPath = const "/"
instance ToQuery GetGroup where
toQuery GetGroup'{..}
= mconcat
["Action" =: ("GetGroup" :: ByteString),
"Version" =: ("2010-05-08" :: ByteString),
"Marker" =: _ggMarker, "MaxItems" =: _ggMaxItems,
"GroupName" =: _ggGroupName]
data GetGroupResponse = GetGroupResponse'
{ _ggrsMarker :: !(Maybe Text)
, _ggrsIsTruncated :: !(Maybe Bool)
, _ggrsResponseStatus :: !Int
, _ggrsGroup :: !Group
, _ggrsUsers :: ![User]
} deriving (Eq,Read,Show,Data,Typeable,Generic)
getGroupResponse
:: Int
-> Group
-> GetGroupResponse
getGroupResponse pResponseStatus_ pGroup_ =
GetGroupResponse'
{ _ggrsMarker = Nothing
, _ggrsIsTruncated = Nothing
, _ggrsResponseStatus = pResponseStatus_
, _ggrsGroup = pGroup_
, _ggrsUsers = mempty
}
ggrsMarker :: Lens' GetGroupResponse (Maybe Text)
ggrsMarker = lens _ggrsMarker (\ s a -> s{_ggrsMarker = a});
ggrsIsTruncated :: Lens' GetGroupResponse (Maybe Bool)
ggrsIsTruncated = lens _ggrsIsTruncated (\ s a -> s{_ggrsIsTruncated = a});
ggrsResponseStatus :: Lens' GetGroupResponse Int
ggrsResponseStatus = lens _ggrsResponseStatus (\ s a -> s{_ggrsResponseStatus = a});
ggrsGroup :: Lens' GetGroupResponse Group
ggrsGroup = lens _ggrsGroup (\ s a -> s{_ggrsGroup = a});
ggrsUsers :: Lens' GetGroupResponse [User]
ggrsUsers = lens _ggrsUsers (\ s a -> s{_ggrsUsers = a}) . _Coerce;