{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE RecordWildCards       #-}
{-# LANGUAGE TupleSections         #-}
{-# LANGUAGE TypeFamilies          #-}
module Aws.Iam.Commands.CreateGroup
    ( CreateGroup(..)
    , CreateGroupResponse(..)
    , Group(..)
    ) 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 group.
--
-- <http://docs.aws.amazon.com/IAM/latest/APIReference/API_CreateGroup.html>
data CreateGroup
    = CreateGroup {
        CreateGroup -> Text
cgGroupName :: Text
      -- ^ Name of the new group
      , CreateGroup -> Maybe Text
cgPath     :: Maybe Text
      -- ^ Path under which the group will be created. Defaults to @/@ if
      -- omitted.
      }
    deriving (CreateGroup -> CreateGroup -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreateGroup -> CreateGroup -> Bool
$c/= :: CreateGroup -> CreateGroup -> Bool
== :: CreateGroup -> CreateGroup -> Bool
$c== :: CreateGroup -> CreateGroup -> Bool
Eq, Eq CreateGroup
CreateGroup -> CreateGroup -> Bool
CreateGroup -> CreateGroup -> Ordering
CreateGroup -> CreateGroup -> CreateGroup
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 :: CreateGroup -> CreateGroup -> CreateGroup
$cmin :: CreateGroup -> CreateGroup -> CreateGroup
max :: CreateGroup -> CreateGroup -> CreateGroup
$cmax :: CreateGroup -> CreateGroup -> CreateGroup
>= :: CreateGroup -> CreateGroup -> Bool
$c>= :: CreateGroup -> CreateGroup -> Bool
> :: CreateGroup -> CreateGroup -> Bool
$c> :: CreateGroup -> CreateGroup -> Bool
<= :: CreateGroup -> CreateGroup -> Bool
$c<= :: CreateGroup -> CreateGroup -> Bool
< :: CreateGroup -> CreateGroup -> Bool
$c< :: CreateGroup -> CreateGroup -> Bool
compare :: CreateGroup -> CreateGroup -> Ordering
$ccompare :: CreateGroup -> CreateGroup -> Ordering
Ord, Int -> CreateGroup -> ShowS
[CreateGroup] -> ShowS
CreateGroup -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreateGroup] -> ShowS
$cshowList :: [CreateGroup] -> ShowS
show :: CreateGroup -> String
$cshow :: CreateGroup -> String
showsPrec :: Int -> CreateGroup -> ShowS
$cshowsPrec :: Int -> CreateGroup -> ShowS
Show, Typeable)

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

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

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

instance Transaction CreateGroup CreateGroupResponse

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