{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE StrictData #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# OPTIONS_GHC -fno-warn-unused-binds #-}
{-# OPTIONS_GHC -fno-warn-unused-imports #-}
{-# OPTIONS_GHC -fno-warn-unused-matches #-}

-- Derived from AWS service descriptions, licensed under Apache 2.0.

-- |
-- Module      : Amazonka.CognitoIdentityProvider.ForgotPassword
-- Copyright   : (c) 2013-2021 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay <brendan.g.hay+amazonka@gmail.com>
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Calling this API causes a message to be sent to the end user with a
-- confirmation code that is required to change the user\'s password. For
-- the @Username@ parameter, you can use the username or user alias. The
-- method used to send the confirmation code is sent according to the
-- specified AccountRecoverySetting. For more information, see
-- <https://docs.aws.amazon.com/cognito/latest/developerguide/how-to-recover-a-user-account.html Recovering User Accounts>
-- in the /Amazon Cognito Developer Guide/. If neither a verified phone
-- number nor a verified email exists, an @InvalidParameterException@ is
-- thrown. To use the confirmation code for resetting the password, call
-- <https://docs.aws.amazon.com/cognito-user-identity-pools/latest/APIReference/API_ConfirmForgotPassword.html ConfirmForgotPassword>.
--
-- This action might generate an SMS text message. Starting June 1, 2021,
-- U.S. telecom carriers require that you register an origination phone
-- number before you can send SMS messages to U.S. phone numbers. If you
-- use SMS text messages in Amazon Cognito, you must register a phone
-- number with
-- <https://console.aws.amazon.com/pinpoint/home/ Amazon Pinpoint>. Cognito
-- will use the the registered number automatically. Otherwise, Cognito
-- users that must receive SMS messages might be unable to sign up,
-- activate their accounts, or sign in.
--
-- If you have never used SMS text messages with Amazon Cognito or any
-- other Amazon Web Service, Amazon SNS might place your account in SMS
-- sandbox. In
-- /<https://docs.aws.amazon.com/sns/latest/dg/sns-sms-sandbox.html sandbox mode>/
-- , you’ll have limitations, such as sending messages to only verified
-- phone numbers. After testing in the sandbox environment, you can move
-- out of the SMS sandbox and into production. For more information, see
-- <https://docs.aws.amazon.com/cognito/latest/developerguide/cognito-user-identity-pools-sms-userpool-settings.html SMS message settings for Cognito User Pools>
-- in the /Amazon Cognito Developer Guide/.
module Amazonka.CognitoIdentityProvider.ForgotPassword
  ( -- * Creating a Request
    ForgotPassword (..),
    newForgotPassword,

    -- * Request Lenses
    forgotPassword_clientMetadata,
    forgotPassword_analyticsMetadata,
    forgotPassword_userContextData,
    forgotPassword_secretHash,
    forgotPassword_clientId,
    forgotPassword_username,

    -- * Destructuring the Response
    ForgotPasswordResponse (..),
    newForgotPasswordResponse,

    -- * Response Lenses
    forgotPasswordResponse_codeDeliveryDetails,
    forgotPasswordResponse_httpStatus,
  )
where

import Amazonka.CognitoIdentityProvider.Types
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response

-- | Represents the request to reset a user\'s password.
--
-- /See:/ 'newForgotPassword' smart constructor.
data ForgotPassword = ForgotPassword'
  { -- | A map of custom key-value pairs that you can provide as input for any
    -- custom workflows that this action triggers.
    --
    -- You create custom workflows by assigning Lambda functions to user pool
    -- triggers. When you use the ForgotPassword API action, Amazon Cognito
    -- invokes any functions that are assigned to the following triggers: /pre
    -- sign-up/, /custom message/, and /user migration/. When Amazon Cognito
    -- invokes any of these functions, it passes a JSON payload, which the
    -- function receives as input. This payload contains a @clientMetadata@
    -- attribute, which provides the data that you assigned to the
    -- ClientMetadata parameter in your ForgotPassword request. In your
    -- function code in Lambda, you can process the @clientMetadata@ value to
    -- enhance your workflow for your specific needs.
    --
    -- For more information, see
    -- <https://docs.aws.amazon.com/cognito/latest/developerguide/cognito-user-identity-pools-working-with-aws-lambda-triggers.html Customizing User Pool Workflows with Lambda Triggers>
    -- in the /Amazon Cognito Developer Guide/.
    --
    -- Take the following limitations into consideration when you use the
    -- ClientMetadata parameter:
    --
    -- -   Amazon Cognito does not store the ClientMetadata value. This data is
    --     available only to Lambda triggers that are assigned to a user pool
    --     to support custom workflows. If your user pool configuration does
    --     not include triggers, the ClientMetadata parameter serves no
    --     purpose.
    --
    -- -   Amazon Cognito does not validate the ClientMetadata value.
    --
    -- -   Amazon Cognito does not encrypt the the ClientMetadata value, so
    --     don\'t use it to provide sensitive information.
    ForgotPassword -> Maybe (HashMap Text Text)
clientMetadata :: Prelude.Maybe (Prelude.HashMap Prelude.Text Prelude.Text),
    -- | The Amazon Pinpoint analytics metadata for collecting metrics for
    -- @ForgotPassword@ calls.
    ForgotPassword -> Maybe AnalyticsMetadataType
analyticsMetadata :: Prelude.Maybe AnalyticsMetadataType,
    -- | Contextual data such as the user\'s device fingerprint, IP address, or
    -- location used for evaluating the risk of an unexpected event by Amazon
    -- Cognito advanced security.
    ForgotPassword -> Maybe UserContextDataType
userContextData :: Prelude.Maybe UserContextDataType,
    -- | A keyed-hash message authentication code (HMAC) calculated using the
    -- secret key of a user pool client and username plus the client ID in the
    -- message.
    ForgotPassword -> Maybe (Sensitive Text)
secretHash :: Prelude.Maybe (Core.Sensitive Prelude.Text),
    -- | The ID of the client associated with the user pool.
    ForgotPassword -> Sensitive Text
clientId :: Core.Sensitive Prelude.Text,
    -- | The user name of the user for whom you want to enter a code to reset a
    -- forgotten password.
    ForgotPassword -> Sensitive Text
username :: Core.Sensitive Prelude.Text
  }
  deriving (ForgotPassword -> ForgotPassword -> Bool
(ForgotPassword -> ForgotPassword -> Bool)
-> (ForgotPassword -> ForgotPassword -> Bool) -> Eq ForgotPassword
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ForgotPassword -> ForgotPassword -> Bool
$c/= :: ForgotPassword -> ForgotPassword -> Bool
== :: ForgotPassword -> ForgotPassword -> Bool
$c== :: ForgotPassword -> ForgotPassword -> Bool
Prelude.Eq, Int -> ForgotPassword -> ShowS
[ForgotPassword] -> ShowS
ForgotPassword -> String
(Int -> ForgotPassword -> ShowS)
-> (ForgotPassword -> String)
-> ([ForgotPassword] -> ShowS)
-> Show ForgotPassword
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ForgotPassword] -> ShowS
$cshowList :: [ForgotPassword] -> ShowS
show :: ForgotPassword -> String
$cshow :: ForgotPassword -> String
showsPrec :: Int -> ForgotPassword -> ShowS
$cshowsPrec :: Int -> ForgotPassword -> ShowS
Prelude.Show, (forall x. ForgotPassword -> Rep ForgotPassword x)
-> (forall x. Rep ForgotPassword x -> ForgotPassword)
-> Generic ForgotPassword
forall x. Rep ForgotPassword x -> ForgotPassword
forall x. ForgotPassword -> Rep ForgotPassword x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ForgotPassword x -> ForgotPassword
$cfrom :: forall x. ForgotPassword -> Rep ForgotPassword x
Prelude.Generic)

-- |
-- Create a value of 'ForgotPassword' with all optional fields omitted.
--
-- Use <https://hackage.haskell.org/package/generic-lens generic-lens> or <https://hackage.haskell.org/package/optics optics> to modify other optional fields.
--
-- The following record fields are available, with the corresponding lenses provided
-- for backwards compatibility:
--
-- 'clientMetadata', 'forgotPassword_clientMetadata' - A map of custom key-value pairs that you can provide as input for any
-- custom workflows that this action triggers.
--
-- You create custom workflows by assigning Lambda functions to user pool
-- triggers. When you use the ForgotPassword API action, Amazon Cognito
-- invokes any functions that are assigned to the following triggers: /pre
-- sign-up/, /custom message/, and /user migration/. When Amazon Cognito
-- invokes any of these functions, it passes a JSON payload, which the
-- function receives as input. This payload contains a @clientMetadata@
-- attribute, which provides the data that you assigned to the
-- ClientMetadata parameter in your ForgotPassword request. In your
-- function code in Lambda, you can process the @clientMetadata@ value to
-- enhance your workflow for your specific needs.
--
-- For more information, see
-- <https://docs.aws.amazon.com/cognito/latest/developerguide/cognito-user-identity-pools-working-with-aws-lambda-triggers.html Customizing User Pool Workflows with Lambda Triggers>
-- in the /Amazon Cognito Developer Guide/.
--
-- Take the following limitations into consideration when you use the
-- ClientMetadata parameter:
--
-- -   Amazon Cognito does not store the ClientMetadata value. This data is
--     available only to Lambda triggers that are assigned to a user pool
--     to support custom workflows. If your user pool configuration does
--     not include triggers, the ClientMetadata parameter serves no
--     purpose.
--
-- -   Amazon Cognito does not validate the ClientMetadata value.
--
-- -   Amazon Cognito does not encrypt the the ClientMetadata value, so
--     don\'t use it to provide sensitive information.
--
-- 'analyticsMetadata', 'forgotPassword_analyticsMetadata' - The Amazon Pinpoint analytics metadata for collecting metrics for
-- @ForgotPassword@ calls.
--
-- 'userContextData', 'forgotPassword_userContextData' - Contextual data such as the user\'s device fingerprint, IP address, or
-- location used for evaluating the risk of an unexpected event by Amazon
-- Cognito advanced security.
--
-- 'secretHash', 'forgotPassword_secretHash' - A keyed-hash message authentication code (HMAC) calculated using the
-- secret key of a user pool client and username plus the client ID in the
-- message.
--
-- 'clientId', 'forgotPassword_clientId' - The ID of the client associated with the user pool.
--
-- 'username', 'forgotPassword_username' - The user name of the user for whom you want to enter a code to reset a
-- forgotten password.
newForgotPassword ::
  -- | 'clientId'
  Prelude.Text ->
  -- | 'username'
  Prelude.Text ->
  ForgotPassword
newForgotPassword :: Text -> Text -> ForgotPassword
newForgotPassword Text
pClientId_ Text
pUsername_ =
  ForgotPassword' :: Maybe (HashMap Text Text)
-> Maybe AnalyticsMetadataType
-> Maybe UserContextDataType
-> Maybe (Sensitive Text)
-> Sensitive Text
-> Sensitive Text
-> ForgotPassword
ForgotPassword'
    { $sel:clientMetadata:ForgotPassword' :: Maybe (HashMap Text Text)
clientMetadata = Maybe (HashMap Text Text)
forall a. Maybe a
Prelude.Nothing,
      $sel:analyticsMetadata:ForgotPassword' :: Maybe AnalyticsMetadataType
analyticsMetadata = Maybe AnalyticsMetadataType
forall a. Maybe a
Prelude.Nothing,
      $sel:userContextData:ForgotPassword' :: Maybe UserContextDataType
userContextData = Maybe UserContextDataType
forall a. Maybe a
Prelude.Nothing,
      $sel:secretHash:ForgotPassword' :: Maybe (Sensitive Text)
secretHash = Maybe (Sensitive Text)
forall a. Maybe a
Prelude.Nothing,
      $sel:clientId:ForgotPassword' :: Sensitive Text
clientId = Tagged Text (Identity Text)
-> Tagged (Sensitive Text) (Identity (Sensitive Text))
forall a. Iso' (Sensitive a) a
Core._Sensitive (Tagged Text (Identity Text)
 -> Tagged (Sensitive Text) (Identity (Sensitive Text)))
-> Text -> Sensitive Text
forall t b. AReview t b -> b -> t
Lens.# Text
pClientId_,
      $sel:username:ForgotPassword' :: Sensitive Text
username = Tagged Text (Identity Text)
-> Tagged (Sensitive Text) (Identity (Sensitive Text))
forall a. Iso' (Sensitive a) a
Core._Sensitive (Tagged Text (Identity Text)
 -> Tagged (Sensitive Text) (Identity (Sensitive Text)))
-> Text -> Sensitive Text
forall t b. AReview t b -> b -> t
Lens.# Text
pUsername_
    }

-- | A map of custom key-value pairs that you can provide as input for any
-- custom workflows that this action triggers.
--
-- You create custom workflows by assigning Lambda functions to user pool
-- triggers. When you use the ForgotPassword API action, Amazon Cognito
-- invokes any functions that are assigned to the following triggers: /pre
-- sign-up/, /custom message/, and /user migration/. When Amazon Cognito
-- invokes any of these functions, it passes a JSON payload, which the
-- function receives as input. This payload contains a @clientMetadata@
-- attribute, which provides the data that you assigned to the
-- ClientMetadata parameter in your ForgotPassword request. In your
-- function code in Lambda, you can process the @clientMetadata@ value to
-- enhance your workflow for your specific needs.
--
-- For more information, see
-- <https://docs.aws.amazon.com/cognito/latest/developerguide/cognito-user-identity-pools-working-with-aws-lambda-triggers.html Customizing User Pool Workflows with Lambda Triggers>
-- in the /Amazon Cognito Developer Guide/.
--
-- Take the following limitations into consideration when you use the
-- ClientMetadata parameter:
--
-- -   Amazon Cognito does not store the ClientMetadata value. This data is
--     available only to Lambda triggers that are assigned to a user pool
--     to support custom workflows. If your user pool configuration does
--     not include triggers, the ClientMetadata parameter serves no
--     purpose.
--
-- -   Amazon Cognito does not validate the ClientMetadata value.
--
-- -   Amazon Cognito does not encrypt the the ClientMetadata value, so
--     don\'t use it to provide sensitive information.
forgotPassword_clientMetadata :: Lens.Lens' ForgotPassword (Prelude.Maybe (Prelude.HashMap Prelude.Text Prelude.Text))
forgotPassword_clientMetadata :: (Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
-> ForgotPassword -> f ForgotPassword
forgotPassword_clientMetadata = (ForgotPassword -> Maybe (HashMap Text Text))
-> (ForgotPassword -> Maybe (HashMap Text Text) -> ForgotPassword)
-> Lens
     ForgotPassword
     ForgotPassword
     (Maybe (HashMap Text Text))
     (Maybe (HashMap Text Text))
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ForgotPassword' {Maybe (HashMap Text Text)
clientMetadata :: Maybe (HashMap Text Text)
$sel:clientMetadata:ForgotPassword' :: ForgotPassword -> Maybe (HashMap Text Text)
clientMetadata} -> Maybe (HashMap Text Text)
clientMetadata) (\s :: ForgotPassword
s@ForgotPassword' {} Maybe (HashMap Text Text)
a -> ForgotPassword
s {$sel:clientMetadata:ForgotPassword' :: Maybe (HashMap Text Text)
clientMetadata = Maybe (HashMap Text Text)
a} :: ForgotPassword) ((Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
 -> ForgotPassword -> f ForgotPassword)
-> ((Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
    -> Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
-> (Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
-> ForgotPassword
-> f ForgotPassword
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  (HashMap Text Text)
  (HashMap Text Text)
  (HashMap Text Text)
  (HashMap Text Text)
-> Iso
     (Maybe (HashMap Text Text))
     (Maybe (HashMap Text Text))
     (Maybe (HashMap Text Text))
     (Maybe (HashMap Text Text))
forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping AnIso
  (HashMap Text Text)
  (HashMap Text Text)
  (HashMap Text Text)
  (HashMap Text Text)
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The Amazon Pinpoint analytics metadata for collecting metrics for
-- @ForgotPassword@ calls.
forgotPassword_analyticsMetadata :: Lens.Lens' ForgotPassword (Prelude.Maybe AnalyticsMetadataType)
forgotPassword_analyticsMetadata :: (Maybe AnalyticsMetadataType -> f (Maybe AnalyticsMetadataType))
-> ForgotPassword -> f ForgotPassword
forgotPassword_analyticsMetadata = (ForgotPassword -> Maybe AnalyticsMetadataType)
-> (ForgotPassword
    -> Maybe AnalyticsMetadataType -> ForgotPassword)
-> Lens
     ForgotPassword
     ForgotPassword
     (Maybe AnalyticsMetadataType)
     (Maybe AnalyticsMetadataType)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ForgotPassword' {Maybe AnalyticsMetadataType
analyticsMetadata :: Maybe AnalyticsMetadataType
$sel:analyticsMetadata:ForgotPassword' :: ForgotPassword -> Maybe AnalyticsMetadataType
analyticsMetadata} -> Maybe AnalyticsMetadataType
analyticsMetadata) (\s :: ForgotPassword
s@ForgotPassword' {} Maybe AnalyticsMetadataType
a -> ForgotPassword
s {$sel:analyticsMetadata:ForgotPassword' :: Maybe AnalyticsMetadataType
analyticsMetadata = Maybe AnalyticsMetadataType
a} :: ForgotPassword)

-- | Contextual data such as the user\'s device fingerprint, IP address, or
-- location used for evaluating the risk of an unexpected event by Amazon
-- Cognito advanced security.
forgotPassword_userContextData :: Lens.Lens' ForgotPassword (Prelude.Maybe UserContextDataType)
forgotPassword_userContextData :: (Maybe UserContextDataType -> f (Maybe UserContextDataType))
-> ForgotPassword -> f ForgotPassword
forgotPassword_userContextData = (ForgotPassword -> Maybe UserContextDataType)
-> (ForgotPassword -> Maybe UserContextDataType -> ForgotPassword)
-> Lens
     ForgotPassword
     ForgotPassword
     (Maybe UserContextDataType)
     (Maybe UserContextDataType)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ForgotPassword' {Maybe UserContextDataType
userContextData :: Maybe UserContextDataType
$sel:userContextData:ForgotPassword' :: ForgotPassword -> Maybe UserContextDataType
userContextData} -> Maybe UserContextDataType
userContextData) (\s :: ForgotPassword
s@ForgotPassword' {} Maybe UserContextDataType
a -> ForgotPassword
s {$sel:userContextData:ForgotPassword' :: Maybe UserContextDataType
userContextData = Maybe UserContextDataType
a} :: ForgotPassword)

-- | A keyed-hash message authentication code (HMAC) calculated using the
-- secret key of a user pool client and username plus the client ID in the
-- message.
forgotPassword_secretHash :: Lens.Lens' ForgotPassword (Prelude.Maybe Prelude.Text)
forgotPassword_secretHash :: (Maybe Text -> f (Maybe Text))
-> ForgotPassword -> f ForgotPassword
forgotPassword_secretHash = (ForgotPassword -> Maybe (Sensitive Text))
-> (ForgotPassword -> Maybe (Sensitive Text) -> ForgotPassword)
-> Lens
     ForgotPassword
     ForgotPassword
     (Maybe (Sensitive Text))
     (Maybe (Sensitive Text))
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ForgotPassword' {Maybe (Sensitive Text)
secretHash :: Maybe (Sensitive Text)
$sel:secretHash:ForgotPassword' :: ForgotPassword -> Maybe (Sensitive Text)
secretHash} -> Maybe (Sensitive Text)
secretHash) (\s :: ForgotPassword
s@ForgotPassword' {} Maybe (Sensitive Text)
a -> ForgotPassword
s {$sel:secretHash:ForgotPassword' :: Maybe (Sensitive Text)
secretHash = Maybe (Sensitive Text)
a} :: ForgotPassword) ((Maybe (Sensitive Text) -> f (Maybe (Sensitive Text)))
 -> ForgotPassword -> f ForgotPassword)
-> ((Maybe Text -> f (Maybe Text))
    -> Maybe (Sensitive Text) -> f (Maybe (Sensitive Text)))
-> (Maybe Text -> f (Maybe Text))
-> ForgotPassword
-> f ForgotPassword
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso (Sensitive Text) (Sensitive Text) Text Text
-> Iso
     (Maybe (Sensitive Text))
     (Maybe (Sensitive Text))
     (Maybe Text)
     (Maybe Text)
forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping AnIso (Sensitive Text) (Sensitive Text) Text Text
forall a. Iso' (Sensitive a) a
Core._Sensitive

-- | The ID of the client associated with the user pool.
forgotPassword_clientId :: Lens.Lens' ForgotPassword Prelude.Text
forgotPassword_clientId :: (Text -> f Text) -> ForgotPassword -> f ForgotPassword
forgotPassword_clientId = (ForgotPassword -> Sensitive Text)
-> (ForgotPassword -> Sensitive Text -> ForgotPassword)
-> Lens
     ForgotPassword ForgotPassword (Sensitive Text) (Sensitive Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ForgotPassword' {Sensitive Text
clientId :: Sensitive Text
$sel:clientId:ForgotPassword' :: ForgotPassword -> Sensitive Text
clientId} -> Sensitive Text
clientId) (\s :: ForgotPassword
s@ForgotPassword' {} Sensitive Text
a -> ForgotPassword
s {$sel:clientId:ForgotPassword' :: Sensitive Text
clientId = Sensitive Text
a} :: ForgotPassword) ((Sensitive Text -> f (Sensitive Text))
 -> ForgotPassword -> f ForgotPassword)
-> ((Text -> f Text) -> Sensitive Text -> f (Sensitive Text))
-> (Text -> f Text)
-> ForgotPassword
-> f ForgotPassword
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (Text -> f Text) -> Sensitive Text -> f (Sensitive Text)
forall a. Iso' (Sensitive a) a
Core._Sensitive

-- | The user name of the user for whom you want to enter a code to reset a
-- forgotten password.
forgotPassword_username :: Lens.Lens' ForgotPassword Prelude.Text
forgotPassword_username :: (Text -> f Text) -> ForgotPassword -> f ForgotPassword
forgotPassword_username = (ForgotPassword -> Sensitive Text)
-> (ForgotPassword -> Sensitive Text -> ForgotPassword)
-> Lens
     ForgotPassword ForgotPassword (Sensitive Text) (Sensitive Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ForgotPassword' {Sensitive Text
username :: Sensitive Text
$sel:username:ForgotPassword' :: ForgotPassword -> Sensitive Text
username} -> Sensitive Text
username) (\s :: ForgotPassword
s@ForgotPassword' {} Sensitive Text
a -> ForgotPassword
s {$sel:username:ForgotPassword' :: Sensitive Text
username = Sensitive Text
a} :: ForgotPassword) ((Sensitive Text -> f (Sensitive Text))
 -> ForgotPassword -> f ForgotPassword)
-> ((Text -> f Text) -> Sensitive Text -> f (Sensitive Text))
-> (Text -> f Text)
-> ForgotPassword
-> f ForgotPassword
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (Text -> f Text) -> Sensitive Text -> f (Sensitive Text)
forall a. Iso' (Sensitive a) a
Core._Sensitive

instance Core.AWSRequest ForgotPassword where
  type
    AWSResponse ForgotPassword =
      ForgotPasswordResponse
  request :: ForgotPassword -> Request ForgotPassword
request = Service -> ForgotPassword -> Request ForgotPassword
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy ForgotPassword
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse ForgotPassword)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse ForgotPassword))
-> Logger
-> Service
-> Proxy ForgotPassword
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse ForgotPassword)))
forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> Object -> Either String (AWSResponse a))
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveJSON
      ( \Int
s ResponseHeaders
h Object
x ->
          Maybe CodeDeliveryDetailsType -> Int -> ForgotPasswordResponse
ForgotPasswordResponse'
            (Maybe CodeDeliveryDetailsType -> Int -> ForgotPasswordResponse)
-> Either String (Maybe CodeDeliveryDetailsType)
-> Either String (Int -> ForgotPasswordResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Either String (Maybe CodeDeliveryDetailsType)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"CodeDeliveryDetails")
            Either String (Int -> ForgotPasswordResponse)
-> Either String Int -> Either String ForgotPasswordResponse
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Int -> Either String Int
forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (Int -> Int
forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
      )

instance Prelude.Hashable ForgotPassword

instance Prelude.NFData ForgotPassword

instance Core.ToHeaders ForgotPassword where
  toHeaders :: ForgotPassword -> ResponseHeaders
toHeaders =
    ResponseHeaders -> ForgotPassword -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const
      ( [ResponseHeaders] -> ResponseHeaders
forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"X-Amz-Target"
              HeaderName -> ByteString -> ResponseHeaders
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Core.=# ( ByteString
"AWSCognitoIdentityProviderService.ForgotPassword" ::
                          Prelude.ByteString
                      ),
            HeaderName
"Content-Type"
              HeaderName -> ByteString -> ResponseHeaders
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Core.=# ( ByteString
"application/x-amz-json-1.1" ::
                          Prelude.ByteString
                      )
          ]
      )

instance Core.ToJSON ForgotPassword where
  toJSON :: ForgotPassword -> Value
toJSON ForgotPassword' {Maybe (HashMap Text Text)
Maybe (Sensitive Text)
Maybe AnalyticsMetadataType
Maybe UserContextDataType
Sensitive Text
username :: Sensitive Text
clientId :: Sensitive Text
secretHash :: Maybe (Sensitive Text)
userContextData :: Maybe UserContextDataType
analyticsMetadata :: Maybe AnalyticsMetadataType
clientMetadata :: Maybe (HashMap Text Text)
$sel:username:ForgotPassword' :: ForgotPassword -> Sensitive Text
$sel:clientId:ForgotPassword' :: ForgotPassword -> Sensitive Text
$sel:secretHash:ForgotPassword' :: ForgotPassword -> Maybe (Sensitive Text)
$sel:userContextData:ForgotPassword' :: ForgotPassword -> Maybe UserContextDataType
$sel:analyticsMetadata:ForgotPassword' :: ForgotPassword -> Maybe AnalyticsMetadataType
$sel:clientMetadata:ForgotPassword' :: ForgotPassword -> Maybe (HashMap Text Text)
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"ClientMetadata" Text -> HashMap Text Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (HashMap Text Text -> Pair)
-> Maybe (HashMap Text Text) -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe (HashMap Text Text)
clientMetadata,
            (Text
"AnalyticsMetadata" Text -> AnalyticsMetadataType -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (AnalyticsMetadataType -> Pair)
-> Maybe AnalyticsMetadataType -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe AnalyticsMetadataType
analyticsMetadata,
            (Text
"UserContextData" Text -> UserContextDataType -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (UserContextDataType -> Pair)
-> Maybe UserContextDataType -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe UserContextDataType
userContextData,
            (Text
"SecretHash" Text -> Sensitive Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Sensitive Text -> Pair) -> Maybe (Sensitive Text) -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe (Sensitive Text)
secretHash,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"ClientId" Text -> Sensitive Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Sensitive Text
clientId),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"Username" Text -> Sensitive Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Sensitive Text
username)
          ]
      )

instance Core.ToPath ForgotPassword where
  toPath :: ForgotPassword -> ByteString
toPath = ByteString -> ForgotPassword -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/"

instance Core.ToQuery ForgotPassword where
  toQuery :: ForgotPassword -> QueryString
toQuery = QueryString -> ForgotPassword -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
forall a. Monoid a => a
Prelude.mempty

-- | Respresents the response from the server regarding the request to reset
-- a password.
--
-- /See:/ 'newForgotPasswordResponse' smart constructor.
data ForgotPasswordResponse = ForgotPasswordResponse'
  { -- | The code delivery details returned by the server in response to the
    -- request to reset a password.
    ForgotPasswordResponse -> Maybe CodeDeliveryDetailsType
codeDeliveryDetails :: Prelude.Maybe CodeDeliveryDetailsType,
    -- | The response's http status code.
    ForgotPasswordResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (ForgotPasswordResponse -> ForgotPasswordResponse -> Bool
(ForgotPasswordResponse -> ForgotPasswordResponse -> Bool)
-> (ForgotPasswordResponse -> ForgotPasswordResponse -> Bool)
-> Eq ForgotPasswordResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ForgotPasswordResponse -> ForgotPasswordResponse -> Bool
$c/= :: ForgotPasswordResponse -> ForgotPasswordResponse -> Bool
== :: ForgotPasswordResponse -> ForgotPasswordResponse -> Bool
$c== :: ForgotPasswordResponse -> ForgotPasswordResponse -> Bool
Prelude.Eq, ReadPrec [ForgotPasswordResponse]
ReadPrec ForgotPasswordResponse
Int -> ReadS ForgotPasswordResponse
ReadS [ForgotPasswordResponse]
(Int -> ReadS ForgotPasswordResponse)
-> ReadS [ForgotPasswordResponse]
-> ReadPrec ForgotPasswordResponse
-> ReadPrec [ForgotPasswordResponse]
-> Read ForgotPasswordResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ForgotPasswordResponse]
$creadListPrec :: ReadPrec [ForgotPasswordResponse]
readPrec :: ReadPrec ForgotPasswordResponse
$creadPrec :: ReadPrec ForgotPasswordResponse
readList :: ReadS [ForgotPasswordResponse]
$creadList :: ReadS [ForgotPasswordResponse]
readsPrec :: Int -> ReadS ForgotPasswordResponse
$creadsPrec :: Int -> ReadS ForgotPasswordResponse
Prelude.Read, Int -> ForgotPasswordResponse -> ShowS
[ForgotPasswordResponse] -> ShowS
ForgotPasswordResponse -> String
(Int -> ForgotPasswordResponse -> ShowS)
-> (ForgotPasswordResponse -> String)
-> ([ForgotPasswordResponse] -> ShowS)
-> Show ForgotPasswordResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ForgotPasswordResponse] -> ShowS
$cshowList :: [ForgotPasswordResponse] -> ShowS
show :: ForgotPasswordResponse -> String
$cshow :: ForgotPasswordResponse -> String
showsPrec :: Int -> ForgotPasswordResponse -> ShowS
$cshowsPrec :: Int -> ForgotPasswordResponse -> ShowS
Prelude.Show, (forall x. ForgotPasswordResponse -> Rep ForgotPasswordResponse x)
-> (forall x.
    Rep ForgotPasswordResponse x -> ForgotPasswordResponse)
-> Generic ForgotPasswordResponse
forall x. Rep ForgotPasswordResponse x -> ForgotPasswordResponse
forall x. ForgotPasswordResponse -> Rep ForgotPasswordResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ForgotPasswordResponse x -> ForgotPasswordResponse
$cfrom :: forall x. ForgotPasswordResponse -> Rep ForgotPasswordResponse x
Prelude.Generic)

-- |
-- Create a value of 'ForgotPasswordResponse' with all optional fields omitted.
--
-- Use <https://hackage.haskell.org/package/generic-lens generic-lens> or <https://hackage.haskell.org/package/optics optics> to modify other optional fields.
--
-- The following record fields are available, with the corresponding lenses provided
-- for backwards compatibility:
--
-- 'codeDeliveryDetails', 'forgotPasswordResponse_codeDeliveryDetails' - The code delivery details returned by the server in response to the
-- request to reset a password.
--
-- 'httpStatus', 'forgotPasswordResponse_httpStatus' - The response's http status code.
newForgotPasswordResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  ForgotPasswordResponse
newForgotPasswordResponse :: Int -> ForgotPasswordResponse
newForgotPasswordResponse Int
pHttpStatus_ =
  ForgotPasswordResponse' :: Maybe CodeDeliveryDetailsType -> Int -> ForgotPasswordResponse
ForgotPasswordResponse'
    { $sel:codeDeliveryDetails:ForgotPasswordResponse' :: Maybe CodeDeliveryDetailsType
codeDeliveryDetails =
        Maybe CodeDeliveryDetailsType
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:ForgotPasswordResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The code delivery details returned by the server in response to the
-- request to reset a password.
forgotPasswordResponse_codeDeliveryDetails :: Lens.Lens' ForgotPasswordResponse (Prelude.Maybe CodeDeliveryDetailsType)
forgotPasswordResponse_codeDeliveryDetails :: (Maybe CodeDeliveryDetailsType
 -> f (Maybe CodeDeliveryDetailsType))
-> ForgotPasswordResponse -> f ForgotPasswordResponse
forgotPasswordResponse_codeDeliveryDetails = (ForgotPasswordResponse -> Maybe CodeDeliveryDetailsType)
-> (ForgotPasswordResponse
    -> Maybe CodeDeliveryDetailsType -> ForgotPasswordResponse)
-> Lens
     ForgotPasswordResponse
     ForgotPasswordResponse
     (Maybe CodeDeliveryDetailsType)
     (Maybe CodeDeliveryDetailsType)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ForgotPasswordResponse' {Maybe CodeDeliveryDetailsType
codeDeliveryDetails :: Maybe CodeDeliveryDetailsType
$sel:codeDeliveryDetails:ForgotPasswordResponse' :: ForgotPasswordResponse -> Maybe CodeDeliveryDetailsType
codeDeliveryDetails} -> Maybe CodeDeliveryDetailsType
codeDeliveryDetails) (\s :: ForgotPasswordResponse
s@ForgotPasswordResponse' {} Maybe CodeDeliveryDetailsType
a -> ForgotPasswordResponse
s {$sel:codeDeliveryDetails:ForgotPasswordResponse' :: Maybe CodeDeliveryDetailsType
codeDeliveryDetails = Maybe CodeDeliveryDetailsType
a} :: ForgotPasswordResponse)

-- | The response's http status code.
forgotPasswordResponse_httpStatus :: Lens.Lens' ForgotPasswordResponse Prelude.Int
forgotPasswordResponse_httpStatus :: (Int -> f Int)
-> ForgotPasswordResponse -> f ForgotPasswordResponse
forgotPasswordResponse_httpStatus = (ForgotPasswordResponse -> Int)
-> (ForgotPasswordResponse -> Int -> ForgotPasswordResponse)
-> Lens ForgotPasswordResponse ForgotPasswordResponse Int Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ForgotPasswordResponse' {Int
httpStatus :: Int
$sel:httpStatus:ForgotPasswordResponse' :: ForgotPasswordResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: ForgotPasswordResponse
s@ForgotPasswordResponse' {} Int
a -> ForgotPasswordResponse
s {$sel:httpStatus:ForgotPasswordResponse' :: Int
httpStatus = Int
a} :: ForgotPasswordResponse)

instance Prelude.NFData ForgotPasswordResponse