{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE RecordWildCards       #-}
{-# LANGUAGE TupleSections         #-}
{-# LANGUAGE TypeFamilies          #-}
module Aws.Iam.Commands.CreateUser
    ( CreateUser(..)
    , CreateUserResponse(..)
    , 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

-- | Creates a new user.
--
-- <http://docs.aws.amazon.com/IAM/latest/APIReference/API_CreateUser.html>
data CreateUser
    = CreateUser {
        CreateUser -> Text
cuUserName :: Text
      -- ^ Name of the new user
      , CreateUser -> Maybe Text
cuPath     :: Maybe Text
      -- ^ Path under which the user will be created. Defaults to @/@ if
      -- omitted.
      }
    deriving (CreateUser -> CreateUser -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreateUser -> CreateUser -> Bool
$c/= :: CreateUser -> CreateUser -> Bool
== :: CreateUser -> CreateUser -> Bool
$c== :: CreateUser -> CreateUser -> Bool
Eq, Eq CreateUser
CreateUser -> CreateUser -> Bool
CreateUser -> CreateUser -> Ordering
CreateUser -> CreateUser -> CreateUser
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 :: CreateUser -> CreateUser -> CreateUser
$cmin :: CreateUser -> CreateUser -> CreateUser
max :: CreateUser -> CreateUser -> CreateUser
$cmax :: CreateUser -> CreateUser -> CreateUser
>= :: CreateUser -> CreateUser -> Bool
$c>= :: CreateUser -> CreateUser -> Bool
> :: CreateUser -> CreateUser -> Bool
$c> :: CreateUser -> CreateUser -> Bool
<= :: CreateUser -> CreateUser -> Bool
$c<= :: CreateUser -> CreateUser -> Bool
< :: CreateUser -> CreateUser -> Bool
$c< :: CreateUser -> CreateUser -> Bool
compare :: CreateUser -> CreateUser -> Ordering
$ccompare :: CreateUser -> CreateUser -> Ordering
Ord, Int -> CreateUser -> ShowS
[CreateUser] -> ShowS
CreateUser -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreateUser] -> ShowS
$cshowList :: [CreateUser] -> ShowS
show :: CreateUser -> String
$cshow :: CreateUser -> String
showsPrec :: Int -> CreateUser -> ShowS
$cshowsPrec :: Int -> CreateUser -> ShowS
Show, Typeable)

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

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

instance ResponseConsumer CreateUser CreateUserResponse where
    type ResponseMetadata CreateUserResponse = IamMetadata
    responseConsumer :: Request
-> CreateUser
-> IORef (ResponseMetadata CreateUserResponse)
-> HTTPResponseConsumer CreateUserResponse
responseConsumer Request
_ CreateUser
_
        = 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 -> CreateUserResponse
CreateUserResponse forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (m :: * -> *). MonadThrow m => Cursor -> m User
parseUser

instance Transaction CreateUser CreateUserResponse

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