module Network.AWS.WorkDocs.CreateUser
(
createUser
, CreateUser
, cuAuthenticationToken
, cuStorageRule
, cuEmailAddress
, cuTimeZoneId
, cuOrganizationId
, cuUsername
, cuGivenName
, cuSurname
, cuPassword
, createUserResponse
, CreateUserResponse
, cursUser
, cursResponseStatus
) where
import Network.AWS.Lens
import Network.AWS.Prelude
import Network.AWS.Request
import Network.AWS.Response
import Network.AWS.WorkDocs.Types
import Network.AWS.WorkDocs.Types.Product
data CreateUser = CreateUser'
{ _cuAuthenticationToken :: !(Maybe (Sensitive Text))
, _cuStorageRule :: !(Maybe StorageRuleType)
, _cuEmailAddress :: !(Maybe Text)
, _cuTimeZoneId :: !(Maybe Text)
, _cuOrganizationId :: !(Maybe Text)
, _cuUsername :: !Text
, _cuGivenName :: !Text
, _cuSurname :: !Text
, _cuPassword :: !(Sensitive Text)
} deriving (Eq, Show, Data, Typeable, Generic)
createUser
:: Text
-> Text
-> Text
-> Text
-> CreateUser
createUser pUsername_ pGivenName_ pSurname_ pPassword_ =
CreateUser'
{ _cuAuthenticationToken = Nothing
, _cuStorageRule = Nothing
, _cuEmailAddress = Nothing
, _cuTimeZoneId = Nothing
, _cuOrganizationId = Nothing
, _cuUsername = pUsername_
, _cuGivenName = pGivenName_
, _cuSurname = pSurname_
, _cuPassword = _Sensitive # pPassword_
}
cuAuthenticationToken :: Lens' CreateUser (Maybe Text)
cuAuthenticationToken = lens _cuAuthenticationToken (\ s a -> s{_cuAuthenticationToken = a}) . mapping _Sensitive;
cuStorageRule :: Lens' CreateUser (Maybe StorageRuleType)
cuStorageRule = lens _cuStorageRule (\ s a -> s{_cuStorageRule = a});
cuEmailAddress :: Lens' CreateUser (Maybe Text)
cuEmailAddress = lens _cuEmailAddress (\ s a -> s{_cuEmailAddress = a});
cuTimeZoneId :: Lens' CreateUser (Maybe Text)
cuTimeZoneId = lens _cuTimeZoneId (\ s a -> s{_cuTimeZoneId = a});
cuOrganizationId :: Lens' CreateUser (Maybe Text)
cuOrganizationId = lens _cuOrganizationId (\ s a -> s{_cuOrganizationId = a});
cuUsername :: Lens' CreateUser Text
cuUsername = lens _cuUsername (\ s a -> s{_cuUsername = a});
cuGivenName :: Lens' CreateUser Text
cuGivenName = lens _cuGivenName (\ s a -> s{_cuGivenName = a});
cuSurname :: Lens' CreateUser Text
cuSurname = lens _cuSurname (\ s a -> s{_cuSurname = a});
cuPassword :: Lens' CreateUser Text
cuPassword = lens _cuPassword (\ s a -> s{_cuPassword = a}) . _Sensitive;
instance AWSRequest CreateUser where
type Rs CreateUser = CreateUserResponse
request = postJSON workDocs
response
= receiveJSON
(\ s h x ->
CreateUserResponse' <$>
(x .?> "User") <*> (pure (fromEnum s)))
instance Hashable CreateUser where
instance NFData CreateUser where
instance ToHeaders CreateUser where
toHeaders CreateUser'{..}
= mconcat
["Authentication" =# _cuAuthenticationToken,
"Content-Type" =#
("application/x-amz-json-1.1" :: ByteString)]
instance ToJSON CreateUser where
toJSON CreateUser'{..}
= object
(catMaybes
[("StorageRule" .=) <$> _cuStorageRule,
("EmailAddress" .=) <$> _cuEmailAddress,
("TimeZoneId" .=) <$> _cuTimeZoneId,
("OrganizationId" .=) <$> _cuOrganizationId,
Just ("Username" .= _cuUsername),
Just ("GivenName" .= _cuGivenName),
Just ("Surname" .= _cuSurname),
Just ("Password" .= _cuPassword)])
instance ToPath CreateUser where
toPath = const "/api/v1/users"
instance ToQuery CreateUser where
toQuery = const mempty
data CreateUserResponse = CreateUserResponse'
{ _cursUser :: !(Maybe User)
, _cursResponseStatus :: !Int
} deriving (Eq, Read, Show, Data, Typeable, Generic)
createUserResponse
:: Int
-> CreateUserResponse
createUserResponse pResponseStatus_ =
CreateUserResponse'
{_cursUser = Nothing, _cursResponseStatus = pResponseStatus_}
cursUser :: Lens' CreateUserResponse (Maybe User)
cursUser = lens _cursUser (\ s a -> s{_cursUser = a});
cursResponseStatus :: Lens' CreateUserResponse Int
cursResponseStatus = lens _cursResponseStatus (\ s a -> s{_cursResponseStatus = a});
instance NFData CreateUserResponse where