module Network.AWS.IAM.GetGroup
(
getGroup
, GetGroup
, ggMaxItems
, ggMarker
, ggGroupName
, getGroupResponse
, GetGroupResponse
, ggrsMarker
, ggrsIsTruncated
, ggrsStatus
, 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'
{ _ggMaxItems :: !(Maybe Nat)
, _ggMarker :: !(Maybe Text)
, _ggGroupName :: !Text
} deriving (Eq,Read,Show,Data,Typeable,Generic)
getGroup
:: Text
-> GetGroup
getGroup pGroupName_ =
GetGroup'
{ _ggMaxItems = Nothing
, _ggMarker = Nothing
, _ggGroupName = pGroupName_
}
ggMaxItems :: Lens' GetGroup (Maybe Natural)
ggMaxItems = lens _ggMaxItems (\ s a -> s{_ggMaxItems = a}) . mapping _Nat;
ggMarker :: Lens' GetGroup (Maybe Text)
ggMarker = lens _ggMarker (\ s a -> s{_ggMarker = a});
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),
"MaxItems" =: _ggMaxItems, "Marker" =: _ggMarker,
"GroupName" =: _ggGroupName]
data GetGroupResponse = GetGroupResponse'
{ _ggrsMarker :: !(Maybe Text)
, _ggrsIsTruncated :: !(Maybe Bool)
, _ggrsStatus :: !Int
, _ggrsGroup :: !Group
, _ggrsUsers :: ![User]
} deriving (Eq,Read,Show,Data,Typeable,Generic)
getGroupResponse
:: Int
-> Group
-> GetGroupResponse
getGroupResponse pStatus_ pGroup_ =
GetGroupResponse'
{ _ggrsMarker = Nothing
, _ggrsIsTruncated = Nothing
, _ggrsStatus = pStatus_
, _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});
ggrsStatus :: Lens' GetGroupResponse Int
ggrsStatus = lens _ggrsStatus (\ s a -> s{_ggrsStatus = 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;