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

instance SignQuery ListMfaDevices where
  type ServiceConfiguration ListMfaDevices = IamConfiguration
  signQuery :: ListMfaDevices
-> ServiceConfiguration ListMfaDevices queryType
-> SignatureData
-> SignedQuery
signQuery ListMfaDevices{Maybe Integer
Maybe Text
lmfaMaxItems :: Maybe Integer
lmfaMarker :: Maybe Text
lmfaUserName :: Maybe Text
lmfaMaxItems :: ListMfaDevices -> Maybe Integer
lmfaMarker :: ListMfaDevices -> Maybe Text
lmfaUserName :: ListMfaDevices -> Maybe Text
..} = 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
/= :: ListMfaDevicesResponse -> ListMfaDevicesResponse -> Bool
$c/= :: ListMfaDevicesResponse -> ListMfaDevicesResponse -> Bool
== :: ListMfaDevicesResponse -> ListMfaDevicesResponse -> Bool
$c== :: 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
min :: ListMfaDevicesResponse
-> ListMfaDevicesResponse -> ListMfaDevicesResponse
$cmin :: ListMfaDevicesResponse
-> ListMfaDevicesResponse -> ListMfaDevicesResponse
max :: ListMfaDevicesResponse
-> ListMfaDevicesResponse -> ListMfaDevicesResponse
$cmax :: ListMfaDevicesResponse
-> ListMfaDevicesResponse -> ListMfaDevicesResponse
>= :: ListMfaDevicesResponse -> ListMfaDevicesResponse -> Bool
$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
compare :: ListMfaDevicesResponse -> ListMfaDevicesResponse -> Ordering
$ccompare :: ListMfaDevicesResponse -> ListMfaDevicesResponse -> Ordering
$cp1Ord :: Eq 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
showList :: [ListMfaDevicesResponse] -> ShowS
$cshowList :: [ListMfaDevicesResponse] -> ShowS
show :: ListMfaDevicesResponse -> String
$cshow :: ListMfaDevicesResponse -> String
showsPrec :: Int -> ListMfaDevicesResponse -> ShowS
$cshowsPrec :: Int -> 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)
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 (m :: * -> *) a. Monad m => a -> m a
return ListMfaDevicesResponse :: [MfaDevice] -> Bool -> Maybe Text -> ListMfaDevicesResponse
ListMfaDevicesResponse{Bool
[MfaDevice]
Maybe Text
lmfarMfaDevices :: [MfaDevice]
lmfarMarker :: Maybe Text
lmfarIsTruncated :: Bool
lmfarMarker :: Maybe Text
lmfarIsTruncated :: Bool
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 :: Maybe Text
lmfaMarker = Text -> Maybe Text
forall a. a -> Maybe a
Just Text
marker }

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