{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE TupleSections #-}
{-# LANGUAGE TypeFamilies #-}
module Aws.Iam.Commands.ListUsers
( ListUsers(..)
, ListUsersResponse(..)
, User(..)
) where
import Aws.Core
import Aws.Iam.Core
import Aws.Iam.Internal
import Control.Applicative
import Data.Text (Text)
import Data.Typeable
import Prelude
import Text.XML.Cursor (laxElement, ($//), (&|))
data ListUsers
= ListUsers {
luPathPrefix :: Maybe Text
, luMarker :: Maybe Text
, luMaxItems :: Maybe Integer
}
deriving (Eq, Ord, Show, Typeable)
instance SignQuery ListUsers where
type ServiceConfiguration ListUsers = IamConfiguration
signQuery ListUsers{..}
= iamAction' "ListUsers" $ [
("PathPrefix",) <$> luPathPrefix
] <> markedIter luMarker luMaxItems
data ListUsersResponse
= ListUsersResponse {
lurUsers :: [User]
, lurIsTruncated :: Bool
, lurMarker :: Maybe Text
}
deriving (Eq, Ord, Show, Typeable)
instance ResponseConsumer ListUsers ListUsersResponse where
type ResponseMetadata ListUsersResponse = IamMetadata
responseConsumer _ _
= iamResponseConsumer $ \cursor -> do
(lurIsTruncated, lurMarker) <- markedIterResponse cursor
lurUsers <- sequence $
cursor $// laxElement "member" &| parseUser
return ListUsersResponse{..}
instance Transaction ListUsers ListUsersResponse
instance IteratedTransaction ListUsers ListUsersResponse where
nextIteratedRequest request response
= case lurMarker response of
Nothing -> Nothing
Just marker -> Just $ request { luMarker = Just marker }
instance AsMemoryResponse ListUsersResponse where
type MemoryResponse ListUsersResponse = ListUsersResponse
loadToMemory = return