    {-# LANGUAGE MultiParamTypeClasses #-}
    {-# LANGUAGE RecordWildCards       #-}
    {-# LANGUAGE TupleSections         #-}
    {-# LANGUAGE TypeFamilies          #-}
    module Aws.Iam.Commands.ListGroups
        ( ListGroups(..)
        , ListGroupsResponse(..)
        , Group(..)
        ) 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, ($//), (&|))

    -- | Lists groups that have the specified path prefix.
    --
    -- <http://docs.aws.amazon.com/IAM/latest/APIReference/API_ListGroups.html>
    data ListGroups
        = ListGroups {
            ListGroups -> Maybe Text
    lgPathPrefix :: Maybe Text
          -- ^ Groups defined under this path will be listed. If omitted, defaults
          -- to @/@, which lists all groups.
          , ListGroups -> Maybe Text
    lgMarker     :: Maybe Text
          -- ^ Used for paginating requests. Marks the position of the last
          -- request.
          , ListGroups -> Maybe Integer
    lgMaxItems   :: Maybe Integer
          -- ^ Used for paginating requests. Specifies the maximum number of items
          -- to return in the response. Defaults to 100.
          }
        deriving (ListGroups -> ListGroups -> Bool
    (ListGroups -> ListGroups -> Bool)
    -> (ListGroups -> ListGroups -> Bool) -> Eq ListGroups
    forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
    $c== :: ListGroups -> ListGroups -> Bool
    == :: ListGroups -> ListGroups -> Bool
    $c/= :: ListGroups -> ListGroups -> Bool
    /= :: ListGroups -> ListGroups -> Bool
    Eq, Eq ListGroups
    Eq ListGroups =>
    (ListGroups -> ListGroups -> Ordering)
    -> (ListGroups -> ListGroups -> Bool)
    -> (ListGroups -> ListGroups -> Bool)
    -> (ListGroups -> ListGroups -> Bool)
    -> (ListGroups -> ListGroups -> Bool)
    -> (ListGroups -> ListGroups -> ListGroups)
    -> (ListGroups -> ListGroups -> ListGroups)
    -> Ord ListGroups
    ListGroups -> ListGroups -> Bool
    ListGroups -> ListGroups -> Ordering
    ListGroups -> ListGroups -> ListGroups
    forall a.
    Eq a =>
    (a -> a -> Ordering)
    -> (a -> a -> Bool)
    -> (a -> a -> Bool)
    -> (a -> a -> Bool)
    -> (a -> a -> Bool)
    -> (a -> a -> a)
    -> (a -> a -> a)
    -> Ord a
    $ccompare :: ListGroups -> ListGroups -> Ordering
    compare :: ListGroups -> ListGroups -> Ordering
    $c< :: ListGroups -> ListGroups -> Bool
    < :: ListGroups -> ListGroups -> Bool
    $c<= :: ListGroups -> ListGroups -> Bool
    <= :: ListGroups -> ListGroups -> Bool
    $c> :: ListGroups -> ListGroups -> Bool
    > :: ListGroups -> ListGroups -> Bool
    $c>= :: ListGroups -> ListGroups -> Bool
    >= :: ListGroups -> ListGroups -> Bool
    $cmax :: ListGroups -> ListGroups -> ListGroups
    max :: ListGroups -> ListGroups -> ListGroups
    $cmin :: ListGroups -> ListGroups -> ListGroups
    min :: ListGroups -> ListGroups -> ListGroups
    Ord, Int -> ListGroups -> ShowS
    [ListGroups] -> ShowS
    ListGroups -> String
    (Int -> ListGroups -> ShowS)
    -> (ListGroups -> String)
    -> ([ListGroups] -> ShowS)
    -> Show ListGroups
    forall a.
    (Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
    $cshowsPrec :: Int -> ListGroups -> ShowS
    showsPrec :: Int -> ListGroups -> ShowS
    $cshow :: ListGroups -> String
    show :: ListGroups -> String
    $cshowList :: [ListGroups] -> ShowS
    showList :: [ListGroups] -> ShowS
    Show, Typeable)

    instance SignQuery ListGroups where
        type ServiceConfiguration ListGroups = IamConfiguration
        signQuery :: forall queryType.
    ListGroups
    -> ServiceConfiguration ListGroups queryType
    -> SignatureData
    -> SignedQuery
    signQuery ListGroups{Maybe Integer
    Maybe Text
    lgPathPrefix :: ListGroups -> Maybe Text
    lgMarker :: ListGroups -> Maybe Text
    lgMaxItems :: ListGroups -> Maybe Integer
    lgPathPrefix :: Maybe Text
    lgMarker :: Maybe Text
    lgMaxItems :: Maybe Integer
    ..}
            = ByteString
    -> [Maybe (ByteString, Text)]
    -> IamConfiguration queryType
    -> SignatureData
    -> SignedQuery
    forall qt.
    ByteString
    -> [Maybe (ByteString, Text)]
    -> IamConfiguration qt
    -> SignatureData
    -> SignedQuery
    iamAction' ByteString
    "ListGroups" ([Maybe (ByteString, Text)]
     -> IamConfiguration queryType -> SignatureData -> SignedQuery)
    -> [Maybe (ByteString, Text)]
    -> IamConfiguration queryType
    -> SignatureData
    -> SignedQuery
    forall a b. (a -> b) -> a -> b
    $ [
                  (ByteString
    "PathPrefix",) (Text -> (ByteString, Text))
    -> Maybe Text -> Maybe (ByteString, Text)
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> Maybe Text
    lgPathPrefix
                ] [Maybe (ByteString, Text)]
    -> [Maybe (ByteString, Text)] -> [Maybe (ByteString, Text)]
    forall a. Semigroup a => a -> a -> a
    <> Maybe Text -> Maybe Integer -> [Maybe (ByteString, Text)]
    markedIter Maybe Text
    lgMarker Maybe Integer
    lgMaxItems

    data ListGroupsResponse
        = ListGroupsResponse {
            ListGroupsResponse -> [Group]
    lgrGroups       :: [Group]
          -- ^ List of 'Group's.
          , ListGroupsResponse -> Bool
    lgrIsTruncated :: Bool
          -- ^ @True@ if the request was truncated because of too many items.
          , ListGroupsResponse -> Maybe Text
    lgrMarker      :: Maybe Text
          -- ^ Marks the position at which the request was truncated. This value
          -- must be passed with the next request to continue listing from the
          -- last position.
          }
        deriving (ListGroupsResponse -> ListGroupsResponse -> Bool
    (ListGroupsResponse -> ListGroupsResponse -> Bool)
    -> (ListGroupsResponse -> ListGroupsResponse -> Bool)
    -> Eq ListGroupsResponse
    forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
    $c== :: ListGroupsResponse -> ListGroupsResponse -> Bool
    == :: ListGroupsResponse -> ListGroupsResponse -> Bool
    $c/= :: ListGroupsResponse -> ListGroupsResponse -> Bool
    /= :: ListGroupsResponse -> ListGroupsResponse -> Bool
    Eq, Eq ListGroupsResponse
    Eq ListGroupsResponse =>
    (ListGroupsResponse -> ListGroupsResponse -> Ordering)
    -> (ListGroupsResponse -> ListGroupsResponse -> Bool)
    -> (ListGroupsResponse -> ListGroupsResponse -> Bool)
    -> (ListGroupsResponse -> ListGroupsResponse -> Bool)
    -> (ListGroupsResponse -> ListGroupsResponse -> Bool)
    -> (ListGroupsResponse -> ListGroupsResponse -> ListGroupsResponse)
    -> (ListGroupsResponse -> ListGroupsResponse -> ListGroupsResponse)
    -> Ord ListGroupsResponse
    ListGroupsResponse -> ListGroupsResponse -> Bool
    ListGroupsResponse -> ListGroupsResponse -> Ordering
    ListGroupsResponse -> ListGroupsResponse -> ListGroupsResponse
    forall a.
    Eq a =>
    (a -> a -> Ordering)
    -> (a -> a -> Bool)
    -> (a -> a -> Bool)
    -> (a -> a -> Bool)
    -> (a -> a -> Bool)
    -> (a -> a -> a)
    -> (a -> a -> a)
    -> Ord a
    $ccompare :: ListGroupsResponse -> ListGroupsResponse -> Ordering
    compare :: ListGroupsResponse -> ListGroupsResponse -> Ordering
    $c< :: ListGroupsResponse -> ListGroupsResponse -> Bool
    < :: ListGroupsResponse -> ListGroupsResponse -> Bool
    $c<= :: ListGroupsResponse -> ListGroupsResponse -> Bool
    <= :: ListGroupsResponse -> ListGroupsResponse -> Bool
    $c> :: ListGroupsResponse -> ListGroupsResponse -> Bool
    > :: ListGroupsResponse -> ListGroupsResponse -> Bool
    $c>= :: ListGroupsResponse -> ListGroupsResponse -> Bool
    >= :: ListGroupsResponse -> ListGroupsResponse -> Bool
    $cmax :: ListGroupsResponse -> ListGroupsResponse -> ListGroupsResponse
    max :: ListGroupsResponse -> ListGroupsResponse -> ListGroupsResponse
    $cmin :: ListGroupsResponse -> ListGroupsResponse -> ListGroupsResponse
    min :: ListGroupsResponse -> ListGroupsResponse -> ListGroupsResponse
    Ord, Int -> ListGroupsResponse -> ShowS
    [ListGroupsResponse] -> ShowS
    ListGroupsResponse -> String
    (Int -> ListGroupsResponse -> ShowS)
    -> (ListGroupsResponse -> String)
    -> ([ListGroupsResponse] -> ShowS)
    -> Show ListGroupsResponse
    forall a.
    (Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
    $cshowsPrec :: Int -> ListGroupsResponse -> ShowS
    showsPrec :: Int -> ListGroupsResponse -> ShowS
    $cshow :: ListGroupsResponse -> String
    show :: ListGroupsResponse -> String
    $cshowList :: [ListGroupsResponse] -> ShowS
    showList :: [ListGroupsResponse] -> ShowS
    Show, Typeable)

    instance ResponseConsumer ListGroups ListGroupsResponse where
        type ResponseMetadata ListGroupsResponse = IamMetadata
        responseConsumer :: Request
    -> ListGroups
    -> IORef (ResponseMetadata ListGroupsResponse)
    -> HTTPResponseConsumer ListGroupsResponse
    responseConsumer Request
    _ ListGroups
    _
            = (Cursor -> Response IamMetadata ListGroupsResponse)
    -> IORef IamMetadata -> HTTPResponseConsumer ListGroupsResponse
    forall a.
    (Cursor -> Response IamMetadata a)
    -> IORef IamMetadata -> HTTPResponseConsumer a
    iamResponseConsumer ((Cursor -> Response IamMetadata ListGroupsResponse)
     -> IORef IamMetadata -> HTTPResponseConsumer ListGroupsResponse)
    -> (Cursor -> Response IamMetadata ListGroupsResponse)
    -> IORef IamMetadata
    -> HTTPResponseConsumer ListGroupsResponse
    forall a b. (a -> b) -> a -> b
    $ \Cursor
    cursor -> do
                (lgrIsTruncated, lgrMarker) <- Cursor -> Response IamMetadata (Bool, Maybe Text)
    forall (m :: * -> *).
    MonadThrow m =>
    Cursor -> m (Bool, Maybe Text)
    markedIterResponse Cursor
    cursor
                lgrGroups <- sequence $
                    cursor $// laxElement "member" &| parseGroup
                return ListGroupsResponse{..}

    instance Transaction ListGroups ListGroupsResponse

    instance IteratedTransaction ListGroups ListGroupsResponse where
        nextIteratedRequest :: ListGroups -> ListGroupsResponse -> Maybe ListGroups
    nextIteratedRequest ListGroups
    request ListGroupsResponse
    response
            = case ListGroupsResponse -> Maybe Text
    lgrMarker ListGroupsResponse
    response of
                Maybe Text
    Nothing     -> Maybe ListGroups
    forall a. Maybe a
    Nothing
                Just Text
    marker -> ListGroups -> Maybe ListGroups
    forall a. a -> Maybe a
    Just (ListGroups -> Maybe ListGroups) -> ListGroups -> Maybe ListGroups
    forall a b. (a -> b) -> a -> b
    $ ListGroups
    request { lgMarker = Just marker }

    instance AsMemoryResponse ListGroupsResponse where
        type MemoryResponse ListGroupsResponse = ListGroupsResponse
        loadToMemory :: ListGroupsResponse
    -> ResourceT IO (MemoryResponse ListGroupsResponse)
    loadToMemory = ListGroupsResponse
    -> ResourceT IO (MemoryResponse ListGroupsResponse)
    ListGroupsResponse -> ResourceT IO ListGroupsResponse
    forall a. a -> ResourceT IO a
    forall (m :: * -> *) a. Monad m => a -> m a
    return