{-# LANGUAGE DeriveDataTypeable #-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE TypeFamilies #-}
{-# OPTIONS_GHC -fno-warn-unused-imports #-}
{-# OPTIONS_GHC -fno-warn-unused-binds #-}
{-# OPTIONS_GHC -fno-warn-unused-matches #-}
module Network.AWS.MQ.CreateUser
(
createUser
, CreateUser
, cuGroups
, cuConsoleAccess
, cuPassword
, cuUsername
, cuBrokerId
, createUserResponse
, CreateUserResponse
, cursResponseStatus
) where
import Network.AWS.Lens
import Network.AWS.MQ.Types
import Network.AWS.MQ.Types.Product
import Network.AWS.Prelude
import Network.AWS.Request
import Network.AWS.Response
data CreateUser = CreateUser'
{ _cuGroups :: !(Maybe [Text])
, _cuConsoleAccess :: !(Maybe Bool)
, _cuPassword :: !(Maybe Text)
, _cuUsername :: !Text
, _cuBrokerId :: !Text
} deriving (Eq, Read, Show, Data, Typeable, Generic)
createUser
:: Text
-> Text
-> CreateUser
createUser pUsername_ pBrokerId_ =
CreateUser'
{ _cuGroups = Nothing
, _cuConsoleAccess = Nothing
, _cuPassword = Nothing
, _cuUsername = pUsername_
, _cuBrokerId = pBrokerId_
}
cuGroups :: Lens' CreateUser [Text]
cuGroups = lens _cuGroups (\ s a -> s{_cuGroups = a}) . _Default . _Coerce
cuConsoleAccess :: Lens' CreateUser (Maybe Bool)
cuConsoleAccess = lens _cuConsoleAccess (\ s a -> s{_cuConsoleAccess = a})
cuPassword :: Lens' CreateUser (Maybe Text)
cuPassword = lens _cuPassword (\ s a -> s{_cuPassword = a})
cuUsername :: Lens' CreateUser Text
cuUsername = lens _cuUsername (\ s a -> s{_cuUsername = a})
cuBrokerId :: Lens' CreateUser Text
cuBrokerId = lens _cuBrokerId (\ s a -> s{_cuBrokerId = a})
instance AWSRequest CreateUser where
type Rs CreateUser = CreateUserResponse
request = postJSON mq
response
= receiveEmpty
(\ s h x ->
CreateUserResponse' <$> (pure (fromEnum s)))
instance Hashable CreateUser where
instance NFData CreateUser where
instance ToHeaders CreateUser where
toHeaders
= const
(mconcat
["Content-Type" =#
("application/x-amz-json-1.1" :: ByteString)])
instance ToJSON CreateUser where
toJSON CreateUser'{..}
= object
(catMaybes
[("groups" .=) <$> _cuGroups,
("consoleAccess" .=) <$> _cuConsoleAccess,
("password" .=) <$> _cuPassword])
instance ToPath CreateUser where
toPath CreateUser'{..}
= mconcat
["/v1/brokers/", toBS _cuBrokerId, "/users/",
toBS _cuUsername]
instance ToQuery CreateUser where
toQuery = const mempty
newtype CreateUserResponse = CreateUserResponse'
{ _cursResponseStatus :: Int
} deriving (Eq, Read, Show, Data, Typeable, Generic)
createUserResponse
:: Int
-> CreateUserResponse
createUserResponse pResponseStatus_ =
CreateUserResponse' {_cursResponseStatus = pResponseStatus_}
cursResponseStatus :: Lens' CreateUserResponse Int
cursResponseStatus = lens _cursResponseStatus (\ s a -> s{_cursResponseStatus = a})
instance NFData CreateUserResponse where