{-# 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
$c== :: ListGroupPolicies -> ListGroupPolicies -> Bool
== :: ListGroupPolicies -> ListGroupPolicies -> Bool
$c/= :: ListGroupPolicies -> ListGroupPolicies -> Bool
/= :: 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
$ccompare :: ListGroupPolicies -> ListGroupPolicies -> Ordering
compare :: ListGroupPolicies -> ListGroupPolicies -> Ordering
$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
>= :: ListGroupPolicies -> ListGroupPolicies -> Bool
$cmax :: ListGroupPolicies -> ListGroupPolicies -> ListGroupPolicies
max :: ListGroupPolicies -> ListGroupPolicies -> ListGroupPolicies
$cmin :: ListGroupPolicies -> ListGroupPolicies -> ListGroupPolicies
min :: ListGroupPolicies -> ListGroupPolicies -> 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
$cshowsPrec :: Int -> ListGroupPolicies -> ShowS
showsPrec :: Int -> ListGroupPolicies -> ShowS
$cshow :: ListGroupPolicies -> String
show :: ListGroupPolicies -> String
$cshowList :: [ListGroupPolicies] -> ShowS
showList :: [ListGroupPolicies] -> ShowS
Show, Typeable)

instance SignQuery ListGroupPolicies where
    type ServiceConfiguration ListGroupPolicies = IamConfiguration
    signQuery :: forall queryType.
ListGroupPolicies
-> ServiceConfiguration ListGroupPolicies queryType
-> SignatureData
-> SignedQuery
signQuery ListGroupPolicies{Maybe Integer
Maybe Text
Text
lgpGroupName :: ListGroupPolicies -> Text
lgpMarker :: ListGroupPolicies -> Maybe Text
lgpMaxItems :: ListGroupPolicies -> Maybe Integer
lgpGroupName :: Text
lgpMarker :: Maybe Text
lgpMaxItems :: Maybe Integer
..}
        = 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
$c== :: ListGroupPoliciesResponse -> ListGroupPoliciesResponse -> Bool
== :: ListGroupPoliciesResponse -> ListGroupPoliciesResponse -> Bool
$c/= :: ListGroupPoliciesResponse -> ListGroupPoliciesResponse -> Bool
/= :: 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
$ccompare :: ListGroupPoliciesResponse -> ListGroupPoliciesResponse -> Ordering
compare :: ListGroupPoliciesResponse -> ListGroupPoliciesResponse -> Ordering
$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
>= :: ListGroupPoliciesResponse -> ListGroupPoliciesResponse -> Bool
$cmax :: ListGroupPoliciesResponse
-> ListGroupPoliciesResponse -> ListGroupPoliciesResponse
max :: ListGroupPoliciesResponse
-> ListGroupPoliciesResponse -> ListGroupPoliciesResponse
$cmin :: ListGroupPoliciesResponse
-> ListGroupPoliciesResponse -> ListGroupPoliciesResponse
min :: ListGroupPoliciesResponse
-> ListGroupPoliciesResponse -> 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
$cshowsPrec :: Int -> ListGroupPoliciesResponse -> ShowS
showsPrec :: Int -> ListGroupPoliciesResponse -> ShowS
$cshow :: ListGroupPoliciesResponse -> String
show :: ListGroupPoliciesResponse -> String
$cshowList :: [ListGroupPoliciesResponse] -> ShowS
showList :: [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 a. a -> Response IamMetadata a
forall (m :: * -> *) a. Monad m => a -> m a
return ListGroupPoliciesResponse{Bool
[Text]
Maybe Text
lgprPolicyNames :: [Text]
lgprIsTruncated :: Bool
lgprMarker :: Maybe Text
lgprIsTruncated :: Bool
lgprMarker :: Maybe Text
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 = Just marker }

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