{-# 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
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
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
Ord, Int -> ListGroupPolicies -> ShowS
[ListGroupPolicies] -> ShowS
ListGroupPolicies -> String
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 :: forall queryType.
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
..}
        = forall qt.
ByteString
-> [Maybe (ByteString, Text)]
-> IamConfiguration qt
-> SignatureData
-> SignedQuery
iamAction' ByteString
"ListGroupPolicies" forall a b. (a -> b) -> a -> b
$ [
              forall a. a -> Maybe a
Just (ByteString
"GroupName", Text
lgpGroupName)
            ] 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
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
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
Ord, Int -> ListGroupPoliciesResponse -> ShowS
[ListGroupPoliciesResponse] -> ShowS
ListGroupPoliciesResponse -> String
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
_
        = forall a.
(Cursor -> Response IamMetadata a)
-> IORef IamMetadata -> HTTPResponseConsumer a
iamResponseConsumer forall a b. (a -> b) -> a -> b
$ \Cursor
cursor -> do
            (Bool
lgprIsTruncated, Maybe Text
lgprMarker) <- forall (m :: * -> *).
MonadThrow m =>
Cursor -> m (Bool, Maybe Text)
markedIterResponse Cursor
cursor
            let lgprPolicyNames :: [Text]
lgprPolicyNames = Cursor
cursor forall node a. Cursor node -> (Cursor node -> [a]) -> [a]
$// Text -> Axis
laxElement Text
"member" forall node a.
Axis node -> (Cursor node -> [a]) -> Cursor node -> [a]
&/ Cursor -> [Text]
content
            forall (m :: * -> *) a. Monad m => a -> m a
return 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     -> forall a. Maybe a
Nothing
            Just Text
marker -> forall a. a -> Maybe a
Just forall a b. (a -> b) -> a -> b
$ ListGroupPolicies
request { lgpMarker :: Maybe Text
lgpMarker = forall a. a -> Maybe a
Just Text
marker }

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