{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE TupleSections #-}
{-# LANGUAGE TypeFamilies #-}
module Aws.Iam.Commands.ListAccessKeys
( ListAccessKeys(..)
, ListAccessKeysResponse(..)
) where
import Aws.Core
import Aws.Iam.Core
import Aws.Iam.Internal
import Control.Applicative
import Data.Text (Text)
import Data.Time
import Data.Typeable
import Prelude
import Text.XML.Cursor (laxElement, ($/), ($//), (&|))
data ListAccessKeys
= ListAccessKeys {
ListAccessKeys -> Maybe Text
lakUserName :: Maybe Text
, ListAccessKeys -> Maybe Text
lakMarker :: Maybe Text
, ListAccessKeys -> Maybe Integer
lakMaxItems :: Maybe Integer
}
deriving (ListAccessKeys -> ListAccessKeys -> Bool
(ListAccessKeys -> ListAccessKeys -> Bool)
-> (ListAccessKeys -> ListAccessKeys -> Bool) -> Eq ListAccessKeys
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListAccessKeys -> ListAccessKeys -> Bool
$c/= :: ListAccessKeys -> ListAccessKeys -> Bool
== :: ListAccessKeys -> ListAccessKeys -> Bool
$c== :: ListAccessKeys -> ListAccessKeys -> Bool
Eq, Eq ListAccessKeys
Eq ListAccessKeys
-> (ListAccessKeys -> ListAccessKeys -> Ordering)
-> (ListAccessKeys -> ListAccessKeys -> Bool)
-> (ListAccessKeys -> ListAccessKeys -> Bool)
-> (ListAccessKeys -> ListAccessKeys -> Bool)
-> (ListAccessKeys -> ListAccessKeys -> Bool)
-> (ListAccessKeys -> ListAccessKeys -> ListAccessKeys)
-> (ListAccessKeys -> ListAccessKeys -> ListAccessKeys)
-> Ord ListAccessKeys
ListAccessKeys -> ListAccessKeys -> Bool
ListAccessKeys -> ListAccessKeys -> Ordering
ListAccessKeys -> ListAccessKeys -> ListAccessKeys
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 :: ListAccessKeys -> ListAccessKeys -> ListAccessKeys
$cmin :: ListAccessKeys -> ListAccessKeys -> ListAccessKeys
max :: ListAccessKeys -> ListAccessKeys -> ListAccessKeys
$cmax :: ListAccessKeys -> ListAccessKeys -> ListAccessKeys
>= :: ListAccessKeys -> ListAccessKeys -> Bool
$c>= :: ListAccessKeys -> ListAccessKeys -> Bool
> :: ListAccessKeys -> ListAccessKeys -> Bool
$c> :: ListAccessKeys -> ListAccessKeys -> Bool
<= :: ListAccessKeys -> ListAccessKeys -> Bool
$c<= :: ListAccessKeys -> ListAccessKeys -> Bool
< :: ListAccessKeys -> ListAccessKeys -> Bool
$c< :: ListAccessKeys -> ListAccessKeys -> Bool
compare :: ListAccessKeys -> ListAccessKeys -> Ordering
$ccompare :: ListAccessKeys -> ListAccessKeys -> Ordering
$cp1Ord :: Eq ListAccessKeys
Ord, Int -> ListAccessKeys -> ShowS
[ListAccessKeys] -> ShowS
ListAccessKeys -> String
(Int -> ListAccessKeys -> ShowS)
-> (ListAccessKeys -> String)
-> ([ListAccessKeys] -> ShowS)
-> Show ListAccessKeys
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListAccessKeys] -> ShowS
$cshowList :: [ListAccessKeys] -> ShowS
show :: ListAccessKeys -> String
$cshow :: ListAccessKeys -> String
showsPrec :: Int -> ListAccessKeys -> ShowS
$cshowsPrec :: Int -> ListAccessKeys -> ShowS
Show, Typeable)
instance SignQuery ListAccessKeys where
type ServiceConfiguration ListAccessKeys = IamConfiguration
signQuery :: ListAccessKeys
-> ServiceConfiguration ListAccessKeys queryType
-> SignatureData
-> SignedQuery
signQuery ListAccessKeys{Maybe Integer
Maybe Text
lakMaxItems :: Maybe Integer
lakMarker :: Maybe Text
lakUserName :: Maybe Text
lakMaxItems :: ListAccessKeys -> Maybe Integer
lakMarker :: ListAccessKeys -> Maybe Text
lakUserName :: ListAccessKeys -> Maybe Text
..}
= ByteString
-> [Maybe (ByteString, Text)]
-> IamConfiguration queryType
-> SignatureData
-> SignedQuery
forall qt.
ByteString
-> [Maybe (ByteString, Text)]
-> IamConfiguration qt
-> SignatureData
-> SignedQuery
iamAction' ByteString
"ListAccessKeys" ([Maybe (ByteString, Text)]
-> IamConfiguration queryType -> SignatureData -> SignedQuery)
-> [Maybe (ByteString, Text)]
-> IamConfiguration queryType
-> SignatureData
-> SignedQuery
forall a b. (a -> b) -> a -> b
$ [
(ByteString
"UserName",) (Text -> (ByteString, Text))
-> Maybe Text -> Maybe (ByteString, Text)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Maybe Text
lakUserName
] [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
lakMarker Maybe Integer
lakMaxItems
data AccessKeyMetadata
= AccessKeyMetadata {
AccessKeyMetadata -> Maybe Text
akmAccessKeyId :: Maybe Text
, AccessKeyMetadata -> Maybe UTCTime
akmCreateDate :: Maybe UTCTime
, AccessKeyMetadata -> Maybe Text
akmStatus :: Maybe Text
, AccessKeyMetadata -> Maybe Text
akmUserName :: Maybe Text
}
deriving (AccessKeyMetadata -> AccessKeyMetadata -> Bool
(AccessKeyMetadata -> AccessKeyMetadata -> Bool)
-> (AccessKeyMetadata -> AccessKeyMetadata -> Bool)
-> Eq AccessKeyMetadata
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AccessKeyMetadata -> AccessKeyMetadata -> Bool
$c/= :: AccessKeyMetadata -> AccessKeyMetadata -> Bool
== :: AccessKeyMetadata -> AccessKeyMetadata -> Bool
$c== :: AccessKeyMetadata -> AccessKeyMetadata -> Bool
Eq, Eq AccessKeyMetadata
Eq AccessKeyMetadata
-> (AccessKeyMetadata -> AccessKeyMetadata -> Ordering)
-> (AccessKeyMetadata -> AccessKeyMetadata -> Bool)
-> (AccessKeyMetadata -> AccessKeyMetadata -> Bool)
-> (AccessKeyMetadata -> AccessKeyMetadata -> Bool)
-> (AccessKeyMetadata -> AccessKeyMetadata -> Bool)
-> (AccessKeyMetadata -> AccessKeyMetadata -> AccessKeyMetadata)
-> (AccessKeyMetadata -> AccessKeyMetadata -> AccessKeyMetadata)
-> Ord AccessKeyMetadata
AccessKeyMetadata -> AccessKeyMetadata -> Bool
AccessKeyMetadata -> AccessKeyMetadata -> Ordering
AccessKeyMetadata -> AccessKeyMetadata -> AccessKeyMetadata
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 :: AccessKeyMetadata -> AccessKeyMetadata -> AccessKeyMetadata
$cmin :: AccessKeyMetadata -> AccessKeyMetadata -> AccessKeyMetadata
max :: AccessKeyMetadata -> AccessKeyMetadata -> AccessKeyMetadata
$cmax :: AccessKeyMetadata -> AccessKeyMetadata -> AccessKeyMetadata
>= :: AccessKeyMetadata -> AccessKeyMetadata -> Bool
$c>= :: AccessKeyMetadata -> AccessKeyMetadata -> Bool
> :: AccessKeyMetadata -> AccessKeyMetadata -> Bool
$c> :: AccessKeyMetadata -> AccessKeyMetadata -> Bool
<= :: AccessKeyMetadata -> AccessKeyMetadata -> Bool
$c<= :: AccessKeyMetadata -> AccessKeyMetadata -> Bool
< :: AccessKeyMetadata -> AccessKeyMetadata -> Bool
$c< :: AccessKeyMetadata -> AccessKeyMetadata -> Bool
compare :: AccessKeyMetadata -> AccessKeyMetadata -> Ordering
$ccompare :: AccessKeyMetadata -> AccessKeyMetadata -> Ordering
$cp1Ord :: Eq AccessKeyMetadata
Ord, Int -> AccessKeyMetadata -> ShowS
[AccessKeyMetadata] -> ShowS
AccessKeyMetadata -> String
(Int -> AccessKeyMetadata -> ShowS)
-> (AccessKeyMetadata -> String)
-> ([AccessKeyMetadata] -> ShowS)
-> Show AccessKeyMetadata
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AccessKeyMetadata] -> ShowS
$cshowList :: [AccessKeyMetadata] -> ShowS
show :: AccessKeyMetadata -> String
$cshow :: AccessKeyMetadata -> String
showsPrec :: Int -> AccessKeyMetadata -> ShowS
$cshowsPrec :: Int -> AccessKeyMetadata -> ShowS
Show, Typeable)
data ListAccessKeysResponse
= ListAccessKeysResponse {
ListAccessKeysResponse -> [AccessKeyMetadata]
lakrAccessKeyMetadata :: [AccessKeyMetadata]
, ListAccessKeysResponse -> Bool
lakrIsTruncated :: Bool
, ListAccessKeysResponse -> Maybe Text
lakrMarker :: Maybe Text
}
deriving (ListAccessKeysResponse -> ListAccessKeysResponse -> Bool
(ListAccessKeysResponse -> ListAccessKeysResponse -> Bool)
-> (ListAccessKeysResponse -> ListAccessKeysResponse -> Bool)
-> Eq ListAccessKeysResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListAccessKeysResponse -> ListAccessKeysResponse -> Bool
$c/= :: ListAccessKeysResponse -> ListAccessKeysResponse -> Bool
== :: ListAccessKeysResponse -> ListAccessKeysResponse -> Bool
$c== :: ListAccessKeysResponse -> ListAccessKeysResponse -> Bool
Eq, Eq ListAccessKeysResponse
Eq ListAccessKeysResponse
-> (ListAccessKeysResponse -> ListAccessKeysResponse -> Ordering)
-> (ListAccessKeysResponse -> ListAccessKeysResponse -> Bool)
-> (ListAccessKeysResponse -> ListAccessKeysResponse -> Bool)
-> (ListAccessKeysResponse -> ListAccessKeysResponse -> Bool)
-> (ListAccessKeysResponse -> ListAccessKeysResponse -> Bool)
-> (ListAccessKeysResponse
-> ListAccessKeysResponse -> ListAccessKeysResponse)
-> (ListAccessKeysResponse
-> ListAccessKeysResponse -> ListAccessKeysResponse)
-> Ord ListAccessKeysResponse
ListAccessKeysResponse -> ListAccessKeysResponse -> Bool
ListAccessKeysResponse -> ListAccessKeysResponse -> Ordering
ListAccessKeysResponse
-> ListAccessKeysResponse -> ListAccessKeysResponse
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 :: ListAccessKeysResponse
-> ListAccessKeysResponse -> ListAccessKeysResponse
$cmin :: ListAccessKeysResponse
-> ListAccessKeysResponse -> ListAccessKeysResponse
max :: ListAccessKeysResponse
-> ListAccessKeysResponse -> ListAccessKeysResponse
$cmax :: ListAccessKeysResponse
-> ListAccessKeysResponse -> ListAccessKeysResponse
>= :: ListAccessKeysResponse -> ListAccessKeysResponse -> Bool
$c>= :: ListAccessKeysResponse -> ListAccessKeysResponse -> Bool
> :: ListAccessKeysResponse -> ListAccessKeysResponse -> Bool
$c> :: ListAccessKeysResponse -> ListAccessKeysResponse -> Bool
<= :: ListAccessKeysResponse -> ListAccessKeysResponse -> Bool
$c<= :: ListAccessKeysResponse -> ListAccessKeysResponse -> Bool
< :: ListAccessKeysResponse -> ListAccessKeysResponse -> Bool
$c< :: ListAccessKeysResponse -> ListAccessKeysResponse -> Bool
compare :: ListAccessKeysResponse -> ListAccessKeysResponse -> Ordering
$ccompare :: ListAccessKeysResponse -> ListAccessKeysResponse -> Ordering
$cp1Ord :: Eq ListAccessKeysResponse
Ord, Int -> ListAccessKeysResponse -> ShowS
[ListAccessKeysResponse] -> ShowS
ListAccessKeysResponse -> String
(Int -> ListAccessKeysResponse -> ShowS)
-> (ListAccessKeysResponse -> String)
-> ([ListAccessKeysResponse] -> ShowS)
-> Show ListAccessKeysResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListAccessKeysResponse] -> ShowS
$cshowList :: [ListAccessKeysResponse] -> ShowS
show :: ListAccessKeysResponse -> String
$cshow :: ListAccessKeysResponse -> String
showsPrec :: Int -> ListAccessKeysResponse -> ShowS
$cshowsPrec :: Int -> ListAccessKeysResponse -> ShowS
Show, Typeable)
instance ResponseConsumer ListAccessKeys ListAccessKeysResponse where
type ResponseMetadata ListAccessKeysResponse = IamMetadata
responseConsumer :: Request
-> ListAccessKeys
-> IORef (ResponseMetadata ListAccessKeysResponse)
-> HTTPResponseConsumer ListAccessKeysResponse
responseConsumer Request
_ ListAccessKeys
_
= (Cursor -> Response IamMetadata ListAccessKeysResponse)
-> IORef IamMetadata -> HTTPResponseConsumer ListAccessKeysResponse
forall a.
(Cursor -> Response IamMetadata a)
-> IORef IamMetadata -> HTTPResponseConsumer a
iamResponseConsumer ((Cursor -> Response IamMetadata ListAccessKeysResponse)
-> IORef IamMetadata
-> HTTPResponseConsumer ListAccessKeysResponse)
-> (Cursor -> Response IamMetadata ListAccessKeysResponse)
-> IORef IamMetadata
-> HTTPResponseConsumer ListAccessKeysResponse
forall a b. (a -> b) -> a -> b
$ \Cursor
cursor -> do
(Bool
lakrIsTruncated, Maybe Text
lakrMarker) <- Cursor -> Response IamMetadata (Bool, Maybe Text)
forall (m :: * -> *).
MonadThrow m =>
Cursor -> m (Bool, Maybe Text)
markedIterResponse Cursor
cursor
[AccessKeyMetadata]
lakrAccessKeyMetadata <- [Response IamMetadata AccessKeyMetadata]
-> Response IamMetadata [AccessKeyMetadata]
forall (t :: * -> *) (m :: * -> *) a.
(Traversable t, Monad m) =>
t (m a) -> m (t a)
sequence ([Response IamMetadata AccessKeyMetadata]
-> Response IamMetadata [AccessKeyMetadata])
-> [Response IamMetadata AccessKeyMetadata]
-> Response IamMetadata [AccessKeyMetadata]
forall a b. (a -> b) -> a -> b
$
Cursor
cursor Cursor
-> (Cursor -> [Response IamMetadata AccessKeyMetadata])
-> [Response IamMetadata AccessKeyMetadata]
forall node a. Cursor node -> (Cursor node -> [a]) -> [a]
$// Text -> Axis
laxElement Text
"member" Axis
-> (Cursor -> Response IamMetadata AccessKeyMetadata)
-> Cursor
-> [Response IamMetadata AccessKeyMetadata]
forall node a b.
(Cursor node -> [a]) -> (a -> b) -> Cursor node -> [b]
&| Cursor -> Response IamMetadata AccessKeyMetadata
forall (m :: * -> *). MonadThrow m => Cursor -> m AccessKeyMetadata
buildAKM
ListAccessKeysResponse
-> Response IamMetadata ListAccessKeysResponse
forall (m :: * -> *) a. Monad m => a -> m a
return ListAccessKeysResponse :: [AccessKeyMetadata] -> Bool -> Maybe Text -> ListAccessKeysResponse
ListAccessKeysResponse{Bool
[AccessKeyMetadata]
Maybe Text
lakrAccessKeyMetadata :: [AccessKeyMetadata]
lakrMarker :: Maybe Text
lakrIsTruncated :: Bool
lakrMarker :: Maybe Text
lakrIsTruncated :: Bool
lakrAccessKeyMetadata :: [AccessKeyMetadata]
..}
where
buildAKM :: Cursor -> m AccessKeyMetadata
buildAKM Cursor
m = do
let mattr :: Text -> Maybe Text
mattr Text
name = [Text] -> Maybe Text
forall a. [a] -> Maybe a
mhead ([Text] -> Maybe Text) -> [Text] -> Maybe Text
forall a b. (a -> b) -> a -> b
$ Cursor
m Cursor -> (Cursor -> [Text]) -> [Text]
forall node a. Cursor node -> (Cursor node -> [a]) -> [a]
$/ Text -> Cursor -> [Text]
elContent Text
name
let akmAccessKeyId :: Maybe Text
akmAccessKeyId = Text -> Maybe Text
mattr Text
"AccessKeyId"
akmStatus :: Maybe Text
akmStatus = Text -> Maybe Text
mattr Text
"Status"
akmUserName :: Maybe Text
akmUserName = Text -> Maybe Text
mattr Text
"UserName"
Maybe UTCTime
akmCreateDate <- case Cursor
m Cursor -> (Cursor -> [String]) -> [String]
forall node a. Cursor node -> (Cursor node -> [a]) -> [a]
$/ Text -> Cursor -> [String]
elCont Text
"CreateDate" of
(String
x:[String]
_) -> UTCTime -> Maybe UTCTime
forall a. a -> Maybe a
Just (UTCTime -> Maybe UTCTime) -> m UTCTime -> m (Maybe UTCTime)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> String -> m UTCTime
forall (m :: * -> *). MonadThrow m => String -> m UTCTime
parseDateTime String
x
[String]
_ -> Maybe UTCTime -> m (Maybe UTCTime)
forall (m :: * -> *) a. Monad m => a -> m a
return Maybe UTCTime
forall a. Maybe a
Nothing
AccessKeyMetadata -> m AccessKeyMetadata
forall (m :: * -> *) a. Monad m => a -> m a
return AccessKeyMetadata :: Maybe Text
-> Maybe UTCTime -> Maybe Text -> Maybe Text -> AccessKeyMetadata
AccessKeyMetadata{Maybe UTCTime
Maybe Text
akmCreateDate :: Maybe UTCTime
akmUserName :: Maybe Text
akmStatus :: Maybe Text
akmAccessKeyId :: Maybe Text
akmUserName :: Maybe Text
akmStatus :: Maybe Text
akmCreateDate :: Maybe UTCTime
akmAccessKeyId :: Maybe Text
..}
mhead :: [a] -> Maybe a
mhead (a
x:[a]
_) = a -> Maybe a
forall a. a -> Maybe a
Just a
x
mhead [a]
_ = Maybe a
forall a. Maybe a
Nothing
instance Transaction ListAccessKeys ListAccessKeysResponse
instance IteratedTransaction ListAccessKeys ListAccessKeysResponse where
nextIteratedRequest :: ListAccessKeys -> ListAccessKeysResponse -> Maybe ListAccessKeys
nextIteratedRequest ListAccessKeys
request ListAccessKeysResponse
response
= case ListAccessKeysResponse -> Maybe Text
lakrMarker ListAccessKeysResponse
response of
Maybe Text
Nothing -> Maybe ListAccessKeys
forall a. Maybe a
Nothing
Just Text
marker -> ListAccessKeys -> Maybe ListAccessKeys
forall a. a -> Maybe a
Just (ListAccessKeys -> Maybe ListAccessKeys)
-> ListAccessKeys -> Maybe ListAccessKeys
forall a b. (a -> b) -> a -> b
$ ListAccessKeys
request { lakMarker :: Maybe Text
lakMarker = Text -> Maybe Text
forall a. a -> Maybe a
Just Text
marker }
instance AsMemoryResponse ListAccessKeysResponse where
type MemoryResponse ListAccessKeysResponse = ListAccessKeysResponse
loadToMemory :: ListAccessKeysResponse
-> ResourceT IO (MemoryResponse ListAccessKeysResponse)
loadToMemory = ListAccessKeysResponse
-> ResourceT IO (MemoryResponse ListAccessKeysResponse)
forall (m :: * -> *) a. Monad m => a -> m a
return