{-# 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-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- 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,
-- US telecom carriers require you to register an origination phone number
-- before you can send SMS messages to US 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>. Amazon
-- Cognito uses the registered number automatically. Otherwise, Amazon
-- Cognito users who must receive SMS messages might not be able 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 Simple Notification Service might place
-- your account in the SMS sandbox. In
-- /<https://docs.aws.amazon.com/sns/latest/dg/sns-sms-sandbox.html sandbox mode>/
-- , you can send messages only to verified phone numbers. After you test
-- your app while in the sandbox environment, you can move out of the
-- 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 Amazon Cognito user pools>
-- in the /Amazon Cognito Developer Guide/.
module Amazonka.CognitoIdentityProvider.ForgotPassword
  ( -- * Creating a Request
    ForgotPassword (..),
    newForgotPassword,

    -- * Request Lenses
    forgotPassword_analyticsMetadata,
    forgotPassword_clientMetadata,
    forgotPassword_secretHash,
    forgotPassword_userContextData,
    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.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
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'
  { -- | The Amazon Pinpoint analytics metadata that contributes to your metrics
    -- for @ForgotPassword@ calls.
    ForgotPassword -> Maybe AnalyticsMetadataType
analyticsMetadata :: Prelude.Maybe AnalyticsMetadataType,
    -- | 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/.
    --
    -- When you use the ClientMetadata parameter, remember that Amazon Cognito
    -- won\'t do the following:
    --
    -- -   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 doesn\'t include
    --     triggers, the ClientMetadata parameter serves no purpose.
    --
    -- -   Validate the ClientMetadata value.
    --
    -- -   Encrypt the ClientMetadata value. Don\'t use Amazon Cognito to
    --     provide sensitive information.
    ForgotPassword -> Maybe (HashMap Text Text)
clientMetadata :: Prelude.Maybe (Prelude.HashMap Prelude.Text Prelude.Text),
    -- | 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 (Data.Sensitive Prelude.Text),
    -- | Contextual data about your user session, such as the device fingerprint,
    -- IP address, or location. Amazon Cognito advanced security evaluates the
    -- risk of an authentication event based on the context that your app
    -- generates and passes to Amazon Cognito when it makes API requests.
    ForgotPassword -> Maybe UserContextDataType
userContextData :: Prelude.Maybe UserContextDataType,
    -- | The ID of the client associated with the user pool.
    ForgotPassword -> Sensitive Text
clientId :: Data.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 :: Data.Sensitive Prelude.Text
  }
  deriving (ForgotPassword -> ForgotPassword -> Bool
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
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. 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:
--
-- 'analyticsMetadata', 'forgotPassword_analyticsMetadata' - The Amazon Pinpoint analytics metadata that contributes to your metrics
-- for @ForgotPassword@ calls.
--
-- '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/.
--
-- When you use the ClientMetadata parameter, remember that Amazon Cognito
-- won\'t do the following:
--
-- -   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 doesn\'t include
--     triggers, the ClientMetadata parameter serves no purpose.
--
-- -   Validate the ClientMetadata value.
--
-- -   Encrypt the ClientMetadata value. Don\'t use Amazon Cognito to
--     provide sensitive information.
--
-- '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.
--
-- 'userContextData', 'forgotPassword_userContextData' - Contextual data about your user session, such as the device fingerprint,
-- IP address, or location. Amazon Cognito advanced security evaluates the
-- risk of an authentication event based on the context that your app
-- generates and passes to Amazon Cognito when it makes API requests.
--
-- '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'
    { $sel:analyticsMetadata:ForgotPassword' :: Maybe AnalyticsMetadataType
analyticsMetadata =
        forall a. Maybe a
Prelude.Nothing,
      $sel:clientMetadata:ForgotPassword' :: Maybe (HashMap Text Text)
clientMetadata = forall a. Maybe a
Prelude.Nothing,
      $sel:secretHash:ForgotPassword' :: Maybe (Sensitive Text)
secretHash = forall a. Maybe a
Prelude.Nothing,
      $sel:userContextData:ForgotPassword' :: Maybe UserContextDataType
userContextData = forall a. Maybe a
Prelude.Nothing,
      $sel:clientId:ForgotPassword' :: Sensitive Text
clientId = forall a. Iso' (Sensitive a) a
Data._Sensitive forall t b. AReview t b -> b -> t
Lens.# Text
pClientId_,
      $sel:username:ForgotPassword' :: Sensitive Text
username = forall a. Iso' (Sensitive a) a
Data._Sensitive forall t b. AReview t b -> b -> t
Lens.# Text
pUsername_
    }

-- | The Amazon Pinpoint analytics metadata that contributes to your metrics
-- for @ForgotPassword@ calls.
forgotPassword_analyticsMetadata :: Lens.Lens' ForgotPassword (Prelude.Maybe AnalyticsMetadataType)
forgotPassword_analyticsMetadata :: Lens' ForgotPassword (Maybe AnalyticsMetadataType)
forgotPassword_analyticsMetadata = 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)

-- | 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/.
--
-- When you use the ClientMetadata parameter, remember that Amazon Cognito
-- won\'t do the following:
--
-- -   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 doesn\'t include
--     triggers, the ClientMetadata parameter serves no purpose.
--
-- -   Validate the ClientMetadata value.
--
-- -   Encrypt the ClientMetadata value. Don\'t use Amazon Cognito to
--     provide sensitive information.
forgotPassword_clientMetadata :: Lens.Lens' ForgotPassword (Prelude.Maybe (Prelude.HashMap Prelude.Text Prelude.Text))
forgotPassword_clientMetadata :: Lens' ForgotPassword (Maybe (HashMap Text Text))
forgotPassword_clientMetadata = 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) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. 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 forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | 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 :: Lens' ForgotPassword (Maybe Text)
forgotPassword_secretHash = 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) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. 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 forall a. Iso' (Sensitive a) a
Data._Sensitive

-- | Contextual data about your user session, such as the device fingerprint,
-- IP address, or location. Amazon Cognito advanced security evaluates the
-- risk of an authentication event based on the context that your app
-- generates and passes to Amazon Cognito when it makes API requests.
forgotPassword_userContextData :: Lens.Lens' ForgotPassword (Prelude.Maybe UserContextDataType)
forgotPassword_userContextData :: Lens' ForgotPassword (Maybe UserContextDataType)
forgotPassword_userContextData = 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)

-- | The ID of the client associated with the user pool.
forgotPassword_clientId :: Lens.Lens' ForgotPassword Prelude.Text
forgotPassword_clientId :: Lens' ForgotPassword Text
forgotPassword_clientId = 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) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall a. Iso' (Sensitive a) a
Data._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 :: Lens' ForgotPassword Text
forgotPassword_username = 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) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall a. Iso' (Sensitive a) a
Data._Sensitive

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

instance Prelude.Hashable ForgotPassword where
  hashWithSalt :: Int -> ForgotPassword -> Int
hashWithSalt Int
_salt ForgotPassword' {Maybe (HashMap Text Text)
Maybe (Sensitive Text)
Maybe AnalyticsMetadataType
Maybe UserContextDataType
Sensitive Text
username :: Sensitive Text
clientId :: Sensitive Text
userContextData :: Maybe UserContextDataType
secretHash :: Maybe (Sensitive Text)
clientMetadata :: Maybe (HashMap Text Text)
analyticsMetadata :: Maybe AnalyticsMetadataType
$sel:username:ForgotPassword' :: ForgotPassword -> Sensitive Text
$sel:clientId:ForgotPassword' :: ForgotPassword -> Sensitive Text
$sel:userContextData:ForgotPassword' :: ForgotPassword -> Maybe UserContextDataType
$sel:secretHash:ForgotPassword' :: ForgotPassword -> Maybe (Sensitive Text)
$sel:clientMetadata:ForgotPassword' :: ForgotPassword -> Maybe (HashMap Text Text)
$sel:analyticsMetadata:ForgotPassword' :: ForgotPassword -> Maybe AnalyticsMetadataType
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe AnalyticsMetadataType
analyticsMetadata
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe (HashMap Text Text)
clientMetadata
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe (Sensitive Text)
secretHash
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe UserContextDataType
userContextData
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Sensitive Text
clientId
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Sensitive Text
username

instance Prelude.NFData ForgotPassword where
  rnf :: ForgotPassword -> ()
rnf ForgotPassword' {Maybe (HashMap Text Text)
Maybe (Sensitive Text)
Maybe AnalyticsMetadataType
Maybe UserContextDataType
Sensitive Text
username :: Sensitive Text
clientId :: Sensitive Text
userContextData :: Maybe UserContextDataType
secretHash :: Maybe (Sensitive Text)
clientMetadata :: Maybe (HashMap Text Text)
analyticsMetadata :: Maybe AnalyticsMetadataType
$sel:username:ForgotPassword' :: ForgotPassword -> Sensitive Text
$sel:clientId:ForgotPassword' :: ForgotPassword -> Sensitive Text
$sel:userContextData:ForgotPassword' :: ForgotPassword -> Maybe UserContextDataType
$sel:secretHash:ForgotPassword' :: ForgotPassword -> Maybe (Sensitive Text)
$sel:clientMetadata:ForgotPassword' :: ForgotPassword -> Maybe (HashMap Text Text)
$sel:analyticsMetadata:ForgotPassword' :: ForgotPassword -> Maybe AnalyticsMetadataType
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe AnalyticsMetadataType
analyticsMetadata
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe (HashMap Text Text)
clientMetadata
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe (Sensitive Text)
secretHash
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe UserContextDataType
userContextData
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Sensitive Text
clientId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Sensitive Text
username

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

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

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

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

-- | The response from Amazon Cognito to a 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
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]
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
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. 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'
    { $sel:codeDeliveryDetails:ForgotPasswordResponse' :: Maybe CodeDeliveryDetailsType
codeDeliveryDetails =
        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 :: Lens' ForgotPasswordResponse (Maybe CodeDeliveryDetailsType)
forgotPasswordResponse_codeDeliveryDetails = 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 :: Lens' ForgotPasswordResponse Int
forgotPasswordResponse_httpStatus = 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 where
  rnf :: ForgotPasswordResponse -> ()
rnf ForgotPasswordResponse' {Int
Maybe CodeDeliveryDetailsType
httpStatus :: Int
codeDeliveryDetails :: Maybe CodeDeliveryDetailsType
$sel:httpStatus:ForgotPasswordResponse' :: ForgotPasswordResponse -> Int
$sel:codeDeliveryDetails:ForgotPasswordResponse' :: ForgotPasswordResponse -> Maybe CodeDeliveryDetailsType
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe CodeDeliveryDetailsType
codeDeliveryDetails
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus