{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE TypeFamilies          #-}
{-# LANGUAGE RecordWildCards       #-}
module Aws.Iam.Commands.ListMfaDevices
       ( ListMfaDevices(..)
       , ListMfaDevicesResponse(..)
       ) 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 the MFA devices. If the request includes the user name,
-- then this action lists all the MFA devices associated with the
-- specified user name. If you do not specify a user name, IAM
-- determines the user name implicitly based on the AWS access key ID
-- signing the request.
--
-- <https://docs.aws.amazon.com/IAM/latest/APIReference/API_ListMFADevices.html>

data ListMfaDevices = ListMfaDevices
                      { ListMfaDevices -> Maybe Text
lmfaUserName :: Maybe Text
                        -- ^ The name of the user whose MFA devices
                        -- you want to list.  If you do not specify a
                        -- user name, IAM determines the user name
                        -- implicitly based on the AWS access key ID
                        -- signing the request
                      , ListMfaDevices -> Maybe Text
lmfaMarker   :: Maybe Text
                        -- ^ Used for paginating requests. Marks the
                        -- position of the last request.
                      , ListMfaDevices -> Maybe Integer
lmfaMaxItems :: Maybe Integer
                        -- ^ Used for paginating requests. Specifies
                        -- the maximum number of items to return in
                        -- the response. Defaults to 100.
                      } deriving (ListMfaDevices -> ListMfaDevices -> Bool
(ListMfaDevices -> ListMfaDevices -> Bool)
-> (ListMfaDevices -> ListMfaDevices -> Bool) -> Eq ListMfaDevices
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: ListMfaDevices -> ListMfaDevices -> Bool
== :: ListMfaDevices -> ListMfaDevices -> Bool
$c/= :: ListMfaDevices -> ListMfaDevices -> Bool
/= :: ListMfaDevices -> ListMfaDevices -> Bool
Eq, Eq ListMfaDevices
Eq ListMfaDevices =>
(ListMfaDevices -> ListMfaDevices -> Ordering)
-> (ListMfaDevices -> ListMfaDevices -> Bool)
-> (ListMfaDevices -> ListMfaDevices -> Bool)
-> (ListMfaDevices -> ListMfaDevices -> Bool)
-> (ListMfaDevices -> ListMfaDevices -> Bool)
-> (ListMfaDevices -> ListMfaDevices -> ListMfaDevices)
-> (ListMfaDevices -> ListMfaDevices -> ListMfaDevices)
-> Ord ListMfaDevices
ListMfaDevices -> ListMfaDevices -> Bool
ListMfaDevices -> ListMfaDevices -> Ordering
ListMfaDevices -> ListMfaDevices -> ListMfaDevices
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 :: ListMfaDevices -> ListMfaDevices -> Ordering
compare :: ListMfaDevices -> ListMfaDevices -> Ordering
$c< :: ListMfaDevices -> ListMfaDevices -> Bool
< :: ListMfaDevices -> ListMfaDevices -> Bool
$c<= :: ListMfaDevices -> ListMfaDevices -> Bool
<= :: ListMfaDevices -> ListMfaDevices -> Bool
$c> :: ListMfaDevices -> ListMfaDevices -> Bool
> :: ListMfaDevices -> ListMfaDevices -> Bool
$c>= :: ListMfaDevices -> ListMfaDevices -> Bool
>= :: ListMfaDevices -> ListMfaDevices -> Bool
$cmax :: ListMfaDevices -> ListMfaDevices -> ListMfaDevices
max :: ListMfaDevices -> ListMfaDevices -> ListMfaDevices
$cmin :: ListMfaDevices -> ListMfaDevices -> ListMfaDevices
min :: ListMfaDevices -> ListMfaDevices -> ListMfaDevices
Ord, Int -> ListMfaDevices -> ShowS
[ListMfaDevices] -> ShowS
ListMfaDevices -> String
(Int -> ListMfaDevices -> ShowS)
-> (ListMfaDevices -> String)
-> ([ListMfaDevices] -> ShowS)
-> Show ListMfaDevices
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> ListMfaDevices -> ShowS
showsPrec :: Int -> ListMfaDevices -> ShowS
$cshow :: ListMfaDevices -> String
show :: ListMfaDevices -> String
$cshowList :: [ListMfaDevices] -> ShowS
showList :: [ListMfaDevices] -> ShowS
Show, Typeable)

instance SignQuery ListMfaDevices where
  type ServiceConfiguration ListMfaDevices = IamConfiguration
  signQuery :: forall queryType.
ListMfaDevices
-> ServiceConfiguration ListMfaDevices queryType
-> SignatureData
-> SignedQuery
signQuery ListMfaDevices{Maybe Integer
Maybe Text
lmfaUserName :: ListMfaDevices -> Maybe Text
lmfaMarker :: ListMfaDevices -> Maybe Text
lmfaMaxItems :: ListMfaDevices -> Maybe Integer
lmfaUserName :: Maybe Text
lmfaMarker :: Maybe Text
lmfaMaxItems :: Maybe Integer
..} = ByteString
-> [Maybe (ByteString, Text)]
-> IamConfiguration queryType
-> SignatureData
-> SignedQuery
forall qt.
ByteString
-> [Maybe (ByteString, Text)]
-> IamConfiguration qt
-> SignatureData
-> SignedQuery
iamAction' ByteString
"ListMFADevices"
                                 ([ (ByteString
"UserName",) (Text -> (ByteString, Text))
-> Maybe Text -> Maybe (ByteString, Text)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Maybe Text
lmfaUserName ]
                                 [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
lmfaMarker Maybe Integer
lmfaMaxItems)

data ListMfaDevicesResponse = ListMfaDevicesResponse
                              { ListMfaDevicesResponse -> [MfaDevice]
lmfarMfaDevices :: [MfaDevice]
                                -- ^ List of 'MFA Device's.
                              , ListMfaDevicesResponse -> Bool
lmfarIsTruncated :: Bool
                                -- ^ @True@ if the request was
                                -- truncated because of too many
                                -- items.
                              , ListMfaDevicesResponse -> Maybe Text
lmfarMarker :: 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 (ListMfaDevicesResponse -> ListMfaDevicesResponse -> Bool
(ListMfaDevicesResponse -> ListMfaDevicesResponse -> Bool)
-> (ListMfaDevicesResponse -> ListMfaDevicesResponse -> Bool)
-> Eq ListMfaDevicesResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: ListMfaDevicesResponse -> ListMfaDevicesResponse -> Bool
== :: ListMfaDevicesResponse -> ListMfaDevicesResponse -> Bool
$c/= :: ListMfaDevicesResponse -> ListMfaDevicesResponse -> Bool
/= :: ListMfaDevicesResponse -> ListMfaDevicesResponse -> Bool
Eq, Eq ListMfaDevicesResponse
Eq ListMfaDevicesResponse =>
(ListMfaDevicesResponse -> ListMfaDevicesResponse -> Ordering)
-> (ListMfaDevicesResponse -> ListMfaDevicesResponse -> Bool)
-> (ListMfaDevicesResponse -> ListMfaDevicesResponse -> Bool)
-> (ListMfaDevicesResponse -> ListMfaDevicesResponse -> Bool)
-> (ListMfaDevicesResponse -> ListMfaDevicesResponse -> Bool)
-> (ListMfaDevicesResponse
    -> ListMfaDevicesResponse -> ListMfaDevicesResponse)
-> (ListMfaDevicesResponse
    -> ListMfaDevicesResponse -> ListMfaDevicesResponse)
-> Ord ListMfaDevicesResponse
ListMfaDevicesResponse -> ListMfaDevicesResponse -> Bool
ListMfaDevicesResponse -> ListMfaDevicesResponse -> Ordering
ListMfaDevicesResponse
-> ListMfaDevicesResponse -> ListMfaDevicesResponse
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 :: ListMfaDevicesResponse -> ListMfaDevicesResponse -> Ordering
compare :: ListMfaDevicesResponse -> ListMfaDevicesResponse -> Ordering
$c< :: ListMfaDevicesResponse -> ListMfaDevicesResponse -> Bool
< :: ListMfaDevicesResponse -> ListMfaDevicesResponse -> Bool
$c<= :: ListMfaDevicesResponse -> ListMfaDevicesResponse -> Bool
<= :: ListMfaDevicesResponse -> ListMfaDevicesResponse -> Bool
$c> :: ListMfaDevicesResponse -> ListMfaDevicesResponse -> Bool
> :: ListMfaDevicesResponse -> ListMfaDevicesResponse -> Bool
$c>= :: ListMfaDevicesResponse -> ListMfaDevicesResponse -> Bool
>= :: ListMfaDevicesResponse -> ListMfaDevicesResponse -> Bool
$cmax :: ListMfaDevicesResponse
-> ListMfaDevicesResponse -> ListMfaDevicesResponse
max :: ListMfaDevicesResponse
-> ListMfaDevicesResponse -> ListMfaDevicesResponse
$cmin :: ListMfaDevicesResponse
-> ListMfaDevicesResponse -> ListMfaDevicesResponse
min :: ListMfaDevicesResponse
-> ListMfaDevicesResponse -> ListMfaDevicesResponse
Ord, Int -> ListMfaDevicesResponse -> ShowS
[ListMfaDevicesResponse] -> ShowS
ListMfaDevicesResponse -> String
(Int -> ListMfaDevicesResponse -> ShowS)
-> (ListMfaDevicesResponse -> String)
-> ([ListMfaDevicesResponse] -> ShowS)
-> Show ListMfaDevicesResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> ListMfaDevicesResponse -> ShowS
showsPrec :: Int -> ListMfaDevicesResponse -> ShowS
$cshow :: ListMfaDevicesResponse -> String
show :: ListMfaDevicesResponse -> String
$cshowList :: [ListMfaDevicesResponse] -> ShowS
showList :: [ListMfaDevicesResponse] -> ShowS
Show, Typeable)

instance ResponseConsumer ListMfaDevices ListMfaDevicesResponse where
  type ResponseMetadata ListMfaDevicesResponse = IamMetadata
  responseConsumer :: Request
-> ListMfaDevices
-> IORef (ResponseMetadata ListMfaDevicesResponse)
-> HTTPResponseConsumer ListMfaDevicesResponse
responseConsumer Request
_ ListMfaDevices
_req =
    (Cursor -> Response IamMetadata ListMfaDevicesResponse)
-> IORef IamMetadata -> HTTPResponseConsumer ListMfaDevicesResponse
forall a.
(Cursor -> Response IamMetadata a)
-> IORef IamMetadata -> HTTPResponseConsumer a
iamResponseConsumer ((Cursor -> Response IamMetadata ListMfaDevicesResponse)
 -> IORef IamMetadata
 -> HTTPResponseConsumer ListMfaDevicesResponse)
-> (Cursor -> Response IamMetadata ListMfaDevicesResponse)
-> IORef IamMetadata
-> HTTPResponseConsumer ListMfaDevicesResponse
forall a b. (a -> b) -> a -> b
$ \ Cursor
cursor -> do
      (Bool
lmfarIsTruncated, Maybe Text
lmfarMarker) <- Cursor -> Response IamMetadata (Bool, Maybe Text)
forall (m :: * -> *).
MonadThrow m =>
Cursor -> m (Bool, Maybe Text)
markedIterResponse Cursor
cursor
      [MfaDevice]
lmfarMfaDevices <-
        [Response IamMetadata MfaDevice]
-> Response IamMetadata [MfaDevice]
forall (t :: * -> *) (m :: * -> *) a.
(Traversable t, Monad m) =>
t (m a) -> m (t a)
forall (m :: * -> *) a. Monad m => [m a] -> m [a]
sequence ([Response IamMetadata MfaDevice]
 -> Response IamMetadata [MfaDevice])
-> [Response IamMetadata MfaDevice]
-> Response IamMetadata [MfaDevice]
forall a b. (a -> b) -> a -> b
$ Cursor
cursor Cursor
-> (Cursor -> [Response IamMetadata MfaDevice])
-> [Response IamMetadata MfaDevice]
forall node a. Cursor node -> (Cursor node -> [a]) -> [a]
$// Text -> Axis
laxElement Text
"member" Axis
-> (Cursor -> Response IamMetadata MfaDevice)
-> Cursor
-> [Response IamMetadata MfaDevice]
forall node a b.
(Cursor node -> [a]) -> (a -> b) -> Cursor node -> [b]
&| Cursor -> Response IamMetadata MfaDevice
forall (m :: * -> *). MonadThrow m => Cursor -> m MfaDevice
parseMfaDevice
      ListMfaDevicesResponse
-> Response IamMetadata ListMfaDevicesResponse
forall a. a -> Response IamMetadata a
forall (m :: * -> *) a. Monad m => a -> m a
return ListMfaDevicesResponse{Bool
[MfaDevice]
Maybe Text
lmfarMfaDevices :: [MfaDevice]
lmfarIsTruncated :: Bool
lmfarMarker :: Maybe Text
lmfarIsTruncated :: Bool
lmfarMarker :: Maybe Text
lmfarMfaDevices :: [MfaDevice]
..}

instance Transaction ListMfaDevices ListMfaDevicesResponse

instance IteratedTransaction ListMfaDevices ListMfaDevicesResponse where
    nextIteratedRequest :: ListMfaDevices -> ListMfaDevicesResponse -> Maybe ListMfaDevices
nextIteratedRequest ListMfaDevices
request ListMfaDevicesResponse
response
        = case ListMfaDevicesResponse -> Maybe Text
lmfarMarker ListMfaDevicesResponse
response of
            Maybe Text
Nothing     -> Maybe ListMfaDevices
forall a. Maybe a
Nothing
            Just Text
marker -> ListMfaDevices -> Maybe ListMfaDevices
forall a. a -> Maybe a
Just (ListMfaDevices -> Maybe ListMfaDevices)
-> ListMfaDevices -> Maybe ListMfaDevices
forall a b. (a -> b) -> a -> b
$ ListMfaDevices
request { lmfaMarker = Just marker }

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