{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE TupleSections         #-}
{-# LANGUAGE TypeFamilies          #-}
module Aws.Iam.Commands.GetUser
    ( GetUser(..)
    , GetUserResponse(..)
    , User(..)
    ) where

import           Aws.Core
import           Aws.Iam.Core
import           Aws.Iam.Internal
import           Control.Applicative
import           Data.Text           (Text)
import           Data.Typeable
import           Prelude

-- | Retreives information about the given user.
--
-- If a user name is not given, IAM determines the user name based on the
-- access key signing the request.
--
-- <http://docs.aws.amazon.com/IAM/latest/APIReference/API_GetUser.html>
data GetUser = GetUser (Maybe Text)
    deriving (GetUser -> GetUser -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetUser -> GetUser -> Bool
$c/= :: GetUser -> GetUser -> Bool
== :: GetUser -> GetUser -> Bool
$c== :: GetUser -> GetUser -> Bool
Eq, Eq GetUser
GetUser -> GetUser -> Bool
GetUser -> GetUser -> Ordering
GetUser -> GetUser -> GetUser
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 :: GetUser -> GetUser -> GetUser
$cmin :: GetUser -> GetUser -> GetUser
max :: GetUser -> GetUser -> GetUser
$cmax :: GetUser -> GetUser -> GetUser
>= :: GetUser -> GetUser -> Bool
$c>= :: GetUser -> GetUser -> Bool
> :: GetUser -> GetUser -> Bool
$c> :: GetUser -> GetUser -> Bool
<= :: GetUser -> GetUser -> Bool
$c<= :: GetUser -> GetUser -> Bool
< :: GetUser -> GetUser -> Bool
$c< :: GetUser -> GetUser -> Bool
compare :: GetUser -> GetUser -> Ordering
$ccompare :: GetUser -> GetUser -> Ordering
Ord, Int -> GetUser -> ShowS
[GetUser] -> ShowS
GetUser -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetUser] -> ShowS
$cshowList :: [GetUser] -> ShowS
show :: GetUser -> String
$cshow :: GetUser -> String
showsPrec :: Int -> GetUser -> ShowS
$cshowsPrec :: Int -> GetUser -> ShowS
Show, Typeable)

instance SignQuery GetUser where
    type ServiceConfiguration GetUser = IamConfiguration
    signQuery :: forall queryType.
GetUser
-> ServiceConfiguration GetUser queryType
-> SignatureData
-> SignedQuery
signQuery (GetUser Maybe Text
user)
        = forall qt.
ByteString
-> [Maybe (ByteString, Text)]
-> IamConfiguration qt
-> SignatureData
-> SignedQuery
iamAction' ByteString
"GetUser" [(ByteString
"UserName",) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Maybe Text
user]

data GetUserResponse = GetUserResponse User
    deriving (GetUserResponse -> GetUserResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetUserResponse -> GetUserResponse -> Bool
$c/= :: GetUserResponse -> GetUserResponse -> Bool
== :: GetUserResponse -> GetUserResponse -> Bool
$c== :: GetUserResponse -> GetUserResponse -> Bool
Eq, Eq GetUserResponse
GetUserResponse -> GetUserResponse -> Bool
GetUserResponse -> GetUserResponse -> Ordering
GetUserResponse -> GetUserResponse -> GetUserResponse
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 :: GetUserResponse -> GetUserResponse -> GetUserResponse
$cmin :: GetUserResponse -> GetUserResponse -> GetUserResponse
max :: GetUserResponse -> GetUserResponse -> GetUserResponse
$cmax :: GetUserResponse -> GetUserResponse -> GetUserResponse
>= :: GetUserResponse -> GetUserResponse -> Bool
$c>= :: GetUserResponse -> GetUserResponse -> Bool
> :: GetUserResponse -> GetUserResponse -> Bool
$c> :: GetUserResponse -> GetUserResponse -> Bool
<= :: GetUserResponse -> GetUserResponse -> Bool
$c<= :: GetUserResponse -> GetUserResponse -> Bool
< :: GetUserResponse -> GetUserResponse -> Bool
$c< :: GetUserResponse -> GetUserResponse -> Bool
compare :: GetUserResponse -> GetUserResponse -> Ordering
$ccompare :: GetUserResponse -> GetUserResponse -> Ordering
Ord, Int -> GetUserResponse -> ShowS
[GetUserResponse] -> ShowS
GetUserResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetUserResponse] -> ShowS
$cshowList :: [GetUserResponse] -> ShowS
show :: GetUserResponse -> String
$cshow :: GetUserResponse -> String
showsPrec :: Int -> GetUserResponse -> ShowS
$cshowsPrec :: Int -> GetUserResponse -> ShowS
Show, Typeable)

instance ResponseConsumer GetUser GetUserResponse where
    type ResponseMetadata GetUserResponse = IamMetadata
    responseConsumer :: Request
-> GetUser
-> IORef (ResponseMetadata GetUserResponse)
-> HTTPResponseConsumer GetUserResponse
responseConsumer Request
_ GetUser
_ = forall a.
(Cursor -> Response IamMetadata a)
-> IORef IamMetadata -> HTTPResponseConsumer a
iamResponseConsumer forall a b. (a -> b) -> a -> b
$
                           forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap User -> GetUserResponse
GetUserResponse forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (m :: * -> *). MonadThrow m => Cursor -> m User
parseUser

instance Transaction GetUser GetUserResponse

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