{-# 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.CognitoIdentityProvider.ForgotPassword
(
forgotPassword
, ForgotPassword
, fpAnalyticsMetadata
, fpUserContextData
, fpSecretHash
, fpClientId
, fpUsername
, forgotPasswordResponse
, ForgotPasswordResponse
, fprsCodeDeliveryDetails
, fprsResponseStatus
) where
import Network.AWS.CognitoIdentityProvider.Types
import Network.AWS.CognitoIdentityProvider.Types.Product
import Network.AWS.Lens
import Network.AWS.Prelude
import Network.AWS.Request
import Network.AWS.Response
data ForgotPassword = ForgotPassword'
{ _fpAnalyticsMetadata :: !(Maybe AnalyticsMetadataType)
, _fpUserContextData :: !(Maybe UserContextDataType)
, _fpSecretHash :: !(Maybe (Sensitive Text))
, _fpClientId :: !(Sensitive Text)
, _fpUsername :: !(Sensitive Text)
} deriving (Eq, Show, Data, Typeable, Generic)
forgotPassword
:: Text
-> Text
-> ForgotPassword
forgotPassword pClientId_ pUsername_ =
ForgotPassword'
{ _fpAnalyticsMetadata = Nothing
, _fpUserContextData = Nothing
, _fpSecretHash = Nothing
, _fpClientId = _Sensitive # pClientId_
, _fpUsername = _Sensitive # pUsername_
}
fpAnalyticsMetadata :: Lens' ForgotPassword (Maybe AnalyticsMetadataType)
fpAnalyticsMetadata = lens _fpAnalyticsMetadata (\ s a -> s{_fpAnalyticsMetadata = a})
fpUserContextData :: Lens' ForgotPassword (Maybe UserContextDataType)
fpUserContextData = lens _fpUserContextData (\ s a -> s{_fpUserContextData = a})
fpSecretHash :: Lens' ForgotPassword (Maybe Text)
fpSecretHash = lens _fpSecretHash (\ s a -> s{_fpSecretHash = a}) . mapping _Sensitive
fpClientId :: Lens' ForgotPassword Text
fpClientId = lens _fpClientId (\ s a -> s{_fpClientId = a}) . _Sensitive
fpUsername :: Lens' ForgotPassword Text
fpUsername = lens _fpUsername (\ s a -> s{_fpUsername = a}) . _Sensitive
instance AWSRequest ForgotPassword where
type Rs ForgotPassword = ForgotPasswordResponse
request = postJSON cognitoIdentityProvider
response
= receiveJSON
(\ s h x ->
ForgotPasswordResponse' <$>
(x .?> "CodeDeliveryDetails") <*>
(pure (fromEnum s)))
instance Hashable ForgotPassword where
instance NFData ForgotPassword where
instance ToHeaders ForgotPassword where
toHeaders
= const
(mconcat
["X-Amz-Target" =#
("AWSCognitoIdentityProviderService.ForgotPassword"
:: ByteString),
"Content-Type" =#
("application/x-amz-json-1.1" :: ByteString)])
instance ToJSON ForgotPassword where
toJSON ForgotPassword'{..}
= object
(catMaybes
[("AnalyticsMetadata" .=) <$> _fpAnalyticsMetadata,
("UserContextData" .=) <$> _fpUserContextData,
("SecretHash" .=) <$> _fpSecretHash,
Just ("ClientId" .= _fpClientId),
Just ("Username" .= _fpUsername)])
instance ToPath ForgotPassword where
toPath = const "/"
instance ToQuery ForgotPassword where
toQuery = const mempty
data ForgotPasswordResponse = ForgotPasswordResponse'
{ _fprsCodeDeliveryDetails :: !(Maybe CodeDeliveryDetailsType)
, _fprsResponseStatus :: !Int
} deriving (Eq, Read, Show, Data, Typeable, Generic)
forgotPasswordResponse
:: Int
-> ForgotPasswordResponse
forgotPasswordResponse pResponseStatus_ =
ForgotPasswordResponse'
{_fprsCodeDeliveryDetails = Nothing, _fprsResponseStatus = pResponseStatus_}
fprsCodeDeliveryDetails :: Lens' ForgotPasswordResponse (Maybe CodeDeliveryDetailsType)
fprsCodeDeliveryDetails = lens _fprsCodeDeliveryDetails (\ s a -> s{_fprsCodeDeliveryDetails = a})
fprsResponseStatus :: Lens' ForgotPasswordResponse Int
fprsResponseStatus = lens _fprsResponseStatus (\ s a -> s{_fprsResponseStatus = a})
instance NFData ForgotPasswordResponse where