{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE RecordWildCards       #-}
{-# LANGUAGE TupleSections         #-}
{-# LANGUAGE TypeFamilies          #-}
module Aws.Iam.Commands.ListGroupPolicies
    ( ListGroupPolicies(..)
    , ListGroupPoliciesResponse(..)
    ) where

import           Aws.Core
import           Aws.Iam.Core
import           Aws.Iam.Internal
import           Data.Text        (Text)
import           Data.Typeable
import           Text.XML.Cursor  (content, laxElement, ($//), (&/))

-- | Lists the group policies associated with the specified group.
--
-- <http://docs.aws.amazon.com/IAM/latest/APIReference/API_ListGroupPolicies.html>
data ListGroupPolicies
    = ListGroupPolicies {
        ListGroupPolicies -> Text
lgpGroupName :: Text
      -- ^ Policies associated with this group will be listed.
      , ListGroupPolicies -> Maybe Text
lgpMarker   :: Maybe Text
      -- ^ Used for paginating requests. Marks the position of the last
      -- request.
      , ListGroupPolicies -> Maybe Integer
lgpMaxItems :: Maybe Integer
      -- ^ Used for paginating requests. Specifies the maximum number of items
      -- to return in the response. Defaults to 100.
      }
    deriving (ListGroupPolicies -> ListGroupPolicies -> Bool
(ListGroupPolicies -> ListGroupPolicies -> Bool)
-> (ListGroupPolicies -> ListGroupPolicies -> Bool)
-> Eq ListGroupPolicies
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListGroupPolicies -> ListGroupPolicies -> Bool
$c/= :: ListGroupPolicies -> ListGroupPolicies -> Bool
== :: ListGroupPolicies -> ListGroupPolicies -> Bool
$c== :: ListGroupPolicies -> ListGroupPolicies -> Bool
Eq, Eq ListGroupPolicies
Eq ListGroupPolicies
-> (ListGroupPolicies -> ListGroupPolicies -> Ordering)
-> (ListGroupPolicies -> ListGroupPolicies -> Bool)
-> (ListGroupPolicies -> ListGroupPolicies -> Bool)
-> (ListGroupPolicies -> ListGroupPolicies -> Bool)
-> (ListGroupPolicies -> ListGroupPolicies -> Bool)
-> (ListGroupPolicies -> ListGroupPolicies -> ListGroupPolicies)
-> (ListGroupPolicies -> ListGroupPolicies -> ListGroupPolicies)
-> Ord ListGroupPolicies
ListGroupPolicies -> ListGroupPolicies -> Bool
ListGroupPolicies -> ListGroupPolicies -> Ordering
ListGroupPolicies -> ListGroupPolicies -> ListGroupPolicies
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
min :: ListGroupPolicies -> ListGroupPolicies -> ListGroupPolicies
$cmin :: ListGroupPolicies -> ListGroupPolicies -> ListGroupPolicies
max :: ListGroupPolicies -> ListGroupPolicies -> ListGroupPolicies
$cmax :: ListGroupPolicies -> ListGroupPolicies -> ListGroupPolicies
>= :: ListGroupPolicies -> ListGroupPolicies -> Bool
$c>= :: ListGroupPolicies -> ListGroupPolicies -> Bool
> :: ListGroupPolicies -> ListGroupPolicies -> Bool
$c> :: ListGroupPolicies -> ListGroupPolicies -> Bool
<= :: ListGroupPolicies -> ListGroupPolicies -> Bool
$c<= :: ListGroupPolicies -> ListGroupPolicies -> Bool
< :: ListGroupPolicies -> ListGroupPolicies -> Bool
$c< :: ListGroupPolicies -> ListGroupPolicies -> Bool
compare :: ListGroupPolicies -> ListGroupPolicies -> Ordering
$ccompare :: ListGroupPolicies -> ListGroupPolicies -> Ordering
$cp1Ord :: Eq ListGroupPolicies
Ord, Int -> ListGroupPolicies -> ShowS
[ListGroupPolicies] -> ShowS
ListGroupPolicies -> String
(Int -> ListGroupPolicies -> ShowS)
-> (ListGroupPolicies -> String)
-> ([ListGroupPolicies] -> ShowS)
-> Show ListGroupPolicies
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListGroupPolicies] -> ShowS
$cshowList :: [ListGroupPolicies] -> ShowS
show :: ListGroupPolicies -> String
$cshow :: ListGroupPolicies -> String
showsPrec :: Int -> ListGroupPolicies -> ShowS
$cshowsPrec :: Int -> ListGroupPolicies -> ShowS
Show, Typeable)

instance SignQuery ListGroupPolicies where
    type ServiceConfiguration ListGroupPolicies = IamConfiguration
    signQuery :: ListGroupPolicies
-> ServiceConfiguration ListGroupPolicies queryType
-> SignatureData
-> SignedQuery
signQuery ListGroupPolicies{Maybe Integer
Maybe Text
Text
lgpMaxItems :: Maybe Integer
lgpMarker :: Maybe Text
lgpGroupName :: Text
lgpMaxItems :: ListGroupPolicies -> Maybe Integer
lgpMarker :: ListGroupPolicies -> Maybe Text
lgpGroupName :: ListGroupPolicies -> Text
..}
        = ByteString
-> [Maybe (ByteString, Text)]
-> IamConfiguration queryType
-> SignatureData
-> SignedQuery
forall qt.
ByteString
-> [Maybe (ByteString, Text)]
-> IamConfiguration qt
-> SignatureData
-> SignedQuery
iamAction' ByteString
"ListGroupPolicies" ([Maybe (ByteString, Text)]
 -> IamConfiguration queryType -> SignatureData -> SignedQuery)
-> [Maybe (ByteString, Text)]
-> IamConfiguration queryType
-> SignatureData
-> SignedQuery
forall a b. (a -> b) -> a -> b
$ [
              (ByteString, Text) -> Maybe (ByteString, Text)
forall a. a -> Maybe a
Just (ByteString
"GroupName", Text
lgpGroupName)
            ] [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
lgpMarker Maybe Integer
lgpMaxItems

data ListGroupPoliciesResponse
    = ListGroupPoliciesResponse {
        ListGroupPoliciesResponse -> [Text]
lgprPolicyNames :: [Text]
      -- ^ List of policy names.
      , ListGroupPoliciesResponse -> Bool
lgprIsTruncated :: Bool
      -- ^ @True@ if the request was truncated because of too many items.
      , ListGroupPoliciesResponse -> Maybe Text
lgprMarker      :: 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 (ListGroupPoliciesResponse -> ListGroupPoliciesResponse -> Bool
(ListGroupPoliciesResponse -> ListGroupPoliciesResponse -> Bool)
-> (ListGroupPoliciesResponse -> ListGroupPoliciesResponse -> Bool)
-> Eq ListGroupPoliciesResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListGroupPoliciesResponse -> ListGroupPoliciesResponse -> Bool
$c/= :: ListGroupPoliciesResponse -> ListGroupPoliciesResponse -> Bool
== :: ListGroupPoliciesResponse -> ListGroupPoliciesResponse -> Bool
$c== :: ListGroupPoliciesResponse -> ListGroupPoliciesResponse -> Bool
Eq, Eq ListGroupPoliciesResponse
Eq ListGroupPoliciesResponse
-> (ListGroupPoliciesResponse
    -> ListGroupPoliciesResponse -> Ordering)
-> (ListGroupPoliciesResponse -> ListGroupPoliciesResponse -> Bool)
-> (ListGroupPoliciesResponse -> ListGroupPoliciesResponse -> Bool)
-> (ListGroupPoliciesResponse -> ListGroupPoliciesResponse -> Bool)
-> (ListGroupPoliciesResponse -> ListGroupPoliciesResponse -> Bool)
-> (ListGroupPoliciesResponse
    -> ListGroupPoliciesResponse -> ListGroupPoliciesResponse)
-> (ListGroupPoliciesResponse
    -> ListGroupPoliciesResponse -> ListGroupPoliciesResponse)
-> Ord ListGroupPoliciesResponse
ListGroupPoliciesResponse -> ListGroupPoliciesResponse -> Bool
ListGroupPoliciesResponse -> ListGroupPoliciesResponse -> Ordering
ListGroupPoliciesResponse
-> ListGroupPoliciesResponse -> ListGroupPoliciesResponse
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
min :: ListGroupPoliciesResponse
-> ListGroupPoliciesResponse -> ListGroupPoliciesResponse
$cmin :: ListGroupPoliciesResponse
-> ListGroupPoliciesResponse -> ListGroupPoliciesResponse
max :: ListGroupPoliciesResponse
-> ListGroupPoliciesResponse -> ListGroupPoliciesResponse
$cmax :: ListGroupPoliciesResponse
-> ListGroupPoliciesResponse -> ListGroupPoliciesResponse
>= :: ListGroupPoliciesResponse -> ListGroupPoliciesResponse -> Bool
$c>= :: ListGroupPoliciesResponse -> ListGroupPoliciesResponse -> Bool
> :: ListGroupPoliciesResponse -> ListGroupPoliciesResponse -> Bool
$c> :: ListGroupPoliciesResponse -> ListGroupPoliciesResponse -> Bool
<= :: ListGroupPoliciesResponse -> ListGroupPoliciesResponse -> Bool
$c<= :: ListGroupPoliciesResponse -> ListGroupPoliciesResponse -> Bool
< :: ListGroupPoliciesResponse -> ListGroupPoliciesResponse -> Bool
$c< :: ListGroupPoliciesResponse -> ListGroupPoliciesResponse -> Bool
compare :: ListGroupPoliciesResponse -> ListGroupPoliciesResponse -> Ordering
$ccompare :: ListGroupPoliciesResponse -> ListGroupPoliciesResponse -> Ordering
$cp1Ord :: Eq ListGroupPoliciesResponse
Ord, Int -> ListGroupPoliciesResponse -> ShowS
[ListGroupPoliciesResponse] -> ShowS
ListGroupPoliciesResponse -> String
(Int -> ListGroupPoliciesResponse -> ShowS)
-> (ListGroupPoliciesResponse -> String)
-> ([ListGroupPoliciesResponse] -> ShowS)
-> Show ListGroupPoliciesResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListGroupPoliciesResponse] -> ShowS
$cshowList :: [ListGroupPoliciesResponse] -> ShowS
show :: ListGroupPoliciesResponse -> String
$cshow :: ListGroupPoliciesResponse -> String
showsPrec :: Int -> ListGroupPoliciesResponse -> ShowS
$cshowsPrec :: Int -> ListGroupPoliciesResponse -> ShowS
Show, Typeable)

instance ResponseConsumer ListGroupPolicies ListGroupPoliciesResponse where
    type ResponseMetadata ListGroupPoliciesResponse = IamMetadata
    responseConsumer :: Request
-> ListGroupPolicies
-> IORef (ResponseMetadata ListGroupPoliciesResponse)
-> HTTPResponseConsumer ListGroupPoliciesResponse
responseConsumer Request
_ ListGroupPolicies
_
        = (Cursor -> Response IamMetadata ListGroupPoliciesResponse)
-> IORef IamMetadata
-> HTTPResponseConsumer ListGroupPoliciesResponse
forall a.
(Cursor -> Response IamMetadata a)
-> IORef IamMetadata -> HTTPResponseConsumer a
iamResponseConsumer ((Cursor -> Response IamMetadata ListGroupPoliciesResponse)
 -> IORef IamMetadata
 -> HTTPResponseConsumer ListGroupPoliciesResponse)
-> (Cursor -> Response IamMetadata ListGroupPoliciesResponse)
-> IORef IamMetadata
-> HTTPResponseConsumer ListGroupPoliciesResponse
forall a b. (a -> b) -> a -> b
$ \Cursor
cursor -> do
            (Bool
lgprIsTruncated, Maybe Text
lgprMarker) <- Cursor -> Response IamMetadata (Bool, Maybe Text)
forall (m :: * -> *).
MonadThrow m =>
Cursor -> m (Bool, Maybe Text)
markedIterResponse Cursor
cursor
            let lgprPolicyNames :: [Text]
lgprPolicyNames = Cursor
cursor Cursor -> (Cursor -> [Text]) -> [Text]
forall node a. Cursor node -> (Cursor node -> [a]) -> [a]
$// Text -> Axis
laxElement Text
"member" Axis -> (Cursor -> [Text]) -> Cursor -> [Text]
forall node a.
Axis node -> (Cursor node -> [a]) -> Cursor node -> [a]
&/ Cursor -> [Text]
content
            ListGroupPoliciesResponse
-> Response IamMetadata ListGroupPoliciesResponse
forall (m :: * -> *) a. Monad m => a -> m a
return ListGroupPoliciesResponse :: [Text] -> Bool -> Maybe Text -> ListGroupPoliciesResponse
ListGroupPoliciesResponse{Bool
[Text]
Maybe Text
lgprPolicyNames :: [Text]
lgprMarker :: Maybe Text
lgprIsTruncated :: Bool
lgprMarker :: Maybe Text
lgprIsTruncated :: Bool
lgprPolicyNames :: [Text]
..}

instance Transaction ListGroupPolicies ListGroupPoliciesResponse

instance IteratedTransaction ListGroupPolicies ListGroupPoliciesResponse where
    nextIteratedRequest :: ListGroupPolicies
-> ListGroupPoliciesResponse -> Maybe ListGroupPolicies
nextIteratedRequest ListGroupPolicies
request ListGroupPoliciesResponse
response
        = case ListGroupPoliciesResponse -> Maybe Text
lgprMarker ListGroupPoliciesResponse
response of
            Maybe Text
Nothing     -> Maybe ListGroupPolicies
forall a. Maybe a
Nothing
            Just Text
marker -> ListGroupPolicies -> Maybe ListGroupPolicies
forall a. a -> Maybe a
Just (ListGroupPolicies -> Maybe ListGroupPolicies)
-> ListGroupPolicies -> Maybe ListGroupPolicies
forall a b. (a -> b) -> a -> b
$ ListGroupPolicies
request { lgpMarker :: Maybe Text
lgpMarker = Text -> Maybe Text
forall a. a -> Maybe a
Just Text
marker }

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