{-# 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
(CreateGroup -> CreateGroup -> Bool)
-> (CreateGroup -> CreateGroup -> Bool) -> Eq CreateGroup
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: CreateGroup -> CreateGroup -> Bool
== :: CreateGroup -> CreateGroup -> Bool
$c/= :: CreateGroup -> CreateGroup -> Bool
/= :: CreateGroup -> CreateGroup -> Bool
Eq, Eq CreateGroup
Eq CreateGroup =>
(CreateGroup -> CreateGroup -> Ordering)
-> (CreateGroup -> CreateGroup -> Bool)
-> (CreateGroup -> CreateGroup -> Bool)
-> (CreateGroup -> CreateGroup -> Bool)
-> (CreateGroup -> CreateGroup -> Bool)
-> (CreateGroup -> CreateGroup -> CreateGroup)
-> (CreateGroup -> CreateGroup -> CreateGroup)
-> Ord 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
$ccompare :: CreateGroup -> CreateGroup -> Ordering
compare :: CreateGroup -> CreateGroup -> Ordering
$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
>= :: CreateGroup -> CreateGroup -> Bool
$cmax :: CreateGroup -> CreateGroup -> CreateGroup
max :: CreateGroup -> CreateGroup -> CreateGroup
$cmin :: CreateGroup -> CreateGroup -> CreateGroup
min :: CreateGroup -> CreateGroup -> CreateGroup
Ord, Int -> CreateGroup -> ShowS
[CreateGroup] -> ShowS
CreateGroup -> String
(Int -> CreateGroup -> ShowS)
-> (CreateGroup -> String)
-> ([CreateGroup] -> ShowS)
-> Show CreateGroup
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> CreateGroup -> ShowS
showsPrec :: Int -> CreateGroup -> ShowS
$cshow :: CreateGroup -> String
show :: CreateGroup -> String
$cshowList :: [CreateGroup] -> ShowS
showList :: [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
cgGroupName :: CreateGroup -> Text
cgPath :: CreateGroup -> Maybe Text
cgGroupName :: Text
cgPath :: Maybe Text
..}
        = ByteString
-> [Maybe (ByteString, Text)]
-> IamConfiguration queryType
-> SignatureData
-> SignedQuery
forall qt.
ByteString
-> [Maybe (ByteString, Text)]
-> IamConfiguration qt
-> SignatureData
-> SignedQuery
iamAction' ByteString
"CreateGroup" [
              (ByteString, Text) -> Maybe (ByteString, Text)
forall a. a -> Maybe a
Just (ByteString
"GroupName", Text
cgGroupName)
            , (ByteString
"Path",) (Text -> (ByteString, Text))
-> Maybe Text -> Maybe (ByteString, Text)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Maybe Text
cgPath
            ]

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

instance ResponseConsumer CreateGroup CreateGroupResponse where
    type ResponseMetadata CreateGroupResponse = IamMetadata
    responseConsumer :: Request
-> CreateGroup
-> IORef (ResponseMetadata CreateGroupResponse)
-> HTTPResponseConsumer CreateGroupResponse
responseConsumer Request
_ CreateGroup
_
        = (Cursor -> Response IamMetadata CreateGroupResponse)
-> IORef IamMetadata -> HTTPResponseConsumer CreateGroupResponse
forall a.
(Cursor -> Response IamMetadata a)
-> IORef IamMetadata -> HTTPResponseConsumer a
iamResponseConsumer ((Cursor -> Response IamMetadata CreateGroupResponse)
 -> IORef IamMetadata -> HTTPResponseConsumer CreateGroupResponse)
-> (Cursor -> Response IamMetadata CreateGroupResponse)
-> IORef IamMetadata
-> HTTPResponseConsumer CreateGroupResponse
forall a b. (a -> b) -> a -> b
$
          (Group -> CreateGroupResponse)
-> Response IamMetadata Group
-> Response IamMetadata CreateGroupResponse
forall a b.
(a -> b) -> Response IamMetadata a -> Response IamMetadata b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap Group -> CreateGroupResponse
CreateGroupResponse (Response IamMetadata Group
 -> Response IamMetadata CreateGroupResponse)
-> (Cursor -> Response IamMetadata Group)
-> Cursor
-> Response IamMetadata CreateGroupResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Cursor -> Response IamMetadata Group
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 = CreateGroupResponse
-> ResourceT IO (MemoryResponse CreateGroupResponse)
CreateGroupResponse -> ResourceT IO CreateGroupResponse
forall a. a -> ResourceT IO a
forall (m :: * -> *) a. Monad m => a -> m a
return