{-# 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.SignUp
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Registers the user in the specified user pool and creates a user name,
-- password, and user attributes.
--
-- 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.SignUp
  ( -- * Creating a Request
    SignUp (..),
    newSignUp,

    -- * Request Lenses
    signUp_analyticsMetadata,
    signUp_clientMetadata,
    signUp_secretHash,
    signUp_userAttributes,
    signUp_userContextData,
    signUp_validationData,
    signUp_clientId,
    signUp_username,
    signUp_password,

    -- * Destructuring the Response
    SignUpResponse (..),
    newSignUpResponse,

    -- * Response Lenses
    signUpResponse_codeDeliveryDetails,
    signUpResponse_httpStatus,
    signUpResponse_userConfirmed,
    signUpResponse_userSub,
  )
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 register a user.
--
-- /See:/ 'newSignUp' smart constructor.
data SignUp = SignUp'
  { -- | The Amazon Pinpoint analytics metadata that contributes to your metrics
    -- for @SignUp@ calls.
    SignUp -> 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 SignUp API action, Amazon Cognito invokes any
    -- functions that are assigned to the following triggers: /pre sign-up/,
    -- /custom message/, and /post confirmation/. 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 SignUp 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.
    SignUp -> 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.
    SignUp -> Maybe (Sensitive Text)
secretHash :: Prelude.Maybe (Data.Sensitive Prelude.Text),
    -- | An array of name-value pairs representing user attributes.
    --
    -- For custom attributes, you must prepend the @custom:@ prefix to the
    -- attribute name.
    SignUp -> Maybe [AttributeType]
userAttributes :: Prelude.Maybe [AttributeType],
    -- | 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.
    SignUp -> Maybe UserContextDataType
userContextData :: Prelude.Maybe UserContextDataType,
    -- | The validation data in the request to register a user.
    SignUp -> Maybe [AttributeType]
validationData :: Prelude.Maybe [AttributeType],
    -- | The ID of the client associated with the user pool.
    SignUp -> Sensitive Text
clientId :: Data.Sensitive Prelude.Text,
    -- | The user name of the user you want to register.
    SignUp -> Sensitive Text
username :: Data.Sensitive Prelude.Text,
    -- | The password of the user you want to register.
    SignUp -> Sensitive Text
password :: Data.Sensitive Prelude.Text
  }
  deriving (SignUp -> SignUp -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SignUp -> SignUp -> Bool
$c/= :: SignUp -> SignUp -> Bool
== :: SignUp -> SignUp -> Bool
$c== :: SignUp -> SignUp -> Bool
Prelude.Eq, Int -> SignUp -> ShowS
[SignUp] -> ShowS
SignUp -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SignUp] -> ShowS
$cshowList :: [SignUp] -> ShowS
show :: SignUp -> String
$cshow :: SignUp -> String
showsPrec :: Int -> SignUp -> ShowS
$cshowsPrec :: Int -> SignUp -> ShowS
Prelude.Show, forall x. Rep SignUp x -> SignUp
forall x. SignUp -> Rep SignUp x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep SignUp x -> SignUp
$cfrom :: forall x. SignUp -> Rep SignUp x
Prelude.Generic)

-- |
-- Create a value of 'SignUp' 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', 'signUp_analyticsMetadata' - The Amazon Pinpoint analytics metadata that contributes to your metrics
-- for @SignUp@ calls.
--
-- 'clientMetadata', 'signUp_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 SignUp API action, Amazon Cognito invokes any
-- functions that are assigned to the following triggers: /pre sign-up/,
-- /custom message/, and /post confirmation/. 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 SignUp 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', 'signUp_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.
--
-- 'userAttributes', 'signUp_userAttributes' - An array of name-value pairs representing user attributes.
--
-- For custom attributes, you must prepend the @custom:@ prefix to the
-- attribute name.
--
-- 'userContextData', 'signUp_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.
--
-- 'validationData', 'signUp_validationData' - The validation data in the request to register a user.
--
-- 'clientId', 'signUp_clientId' - The ID of the client associated with the user pool.
--
-- 'username', 'signUp_username' - The user name of the user you want to register.
--
-- 'password', 'signUp_password' - The password of the user you want to register.
newSignUp ::
  -- | 'clientId'
  Prelude.Text ->
  -- | 'username'
  Prelude.Text ->
  -- | 'password'
  Prelude.Text ->
  SignUp
newSignUp :: Text -> Text -> Text -> SignUp
newSignUp Text
pClientId_ Text
pUsername_ Text
pPassword_ =
  SignUp'
    { $sel:analyticsMetadata:SignUp' :: Maybe AnalyticsMetadataType
analyticsMetadata = forall a. Maybe a
Prelude.Nothing,
      $sel:clientMetadata:SignUp' :: Maybe (HashMap Text Text)
clientMetadata = forall a. Maybe a
Prelude.Nothing,
      $sel:secretHash:SignUp' :: Maybe (Sensitive Text)
secretHash = forall a. Maybe a
Prelude.Nothing,
      $sel:userAttributes:SignUp' :: Maybe [AttributeType]
userAttributes = forall a. Maybe a
Prelude.Nothing,
      $sel:userContextData:SignUp' :: Maybe UserContextDataType
userContextData = forall a. Maybe a
Prelude.Nothing,
      $sel:validationData:SignUp' :: Maybe [AttributeType]
validationData = forall a. Maybe a
Prelude.Nothing,
      $sel:clientId:SignUp' :: Sensitive Text
clientId = forall a. Iso' (Sensitive a) a
Data._Sensitive forall t b. AReview t b -> b -> t
Lens.# Text
pClientId_,
      $sel:username:SignUp' :: Sensitive Text
username = forall a. Iso' (Sensitive a) a
Data._Sensitive forall t b. AReview t b -> b -> t
Lens.# Text
pUsername_,
      $sel:password:SignUp' :: Sensitive Text
password = forall a. Iso' (Sensitive a) a
Data._Sensitive forall t b. AReview t b -> b -> t
Lens.# Text
pPassword_
    }

-- | The Amazon Pinpoint analytics metadata that contributes to your metrics
-- for @SignUp@ calls.
signUp_analyticsMetadata :: Lens.Lens' SignUp (Prelude.Maybe AnalyticsMetadataType)
signUp_analyticsMetadata :: Lens' SignUp (Maybe AnalyticsMetadataType)
signUp_analyticsMetadata = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SignUp' {Maybe AnalyticsMetadataType
analyticsMetadata :: Maybe AnalyticsMetadataType
$sel:analyticsMetadata:SignUp' :: SignUp -> Maybe AnalyticsMetadataType
analyticsMetadata} -> Maybe AnalyticsMetadataType
analyticsMetadata) (\s :: SignUp
s@SignUp' {} Maybe AnalyticsMetadataType
a -> SignUp
s {$sel:analyticsMetadata:SignUp' :: Maybe AnalyticsMetadataType
analyticsMetadata = Maybe AnalyticsMetadataType
a} :: SignUp)

-- | 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 SignUp API action, Amazon Cognito invokes any
-- functions that are assigned to the following triggers: /pre sign-up/,
-- /custom message/, and /post confirmation/. 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 SignUp 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.
signUp_clientMetadata :: Lens.Lens' SignUp (Prelude.Maybe (Prelude.HashMap Prelude.Text Prelude.Text))
signUp_clientMetadata :: Lens' SignUp (Maybe (HashMap Text Text))
signUp_clientMetadata = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SignUp' {Maybe (HashMap Text Text)
clientMetadata :: Maybe (HashMap Text Text)
$sel:clientMetadata:SignUp' :: SignUp -> Maybe (HashMap Text Text)
clientMetadata} -> Maybe (HashMap Text Text)
clientMetadata) (\s :: SignUp
s@SignUp' {} Maybe (HashMap Text Text)
a -> SignUp
s {$sel:clientMetadata:SignUp' :: Maybe (HashMap Text Text)
clientMetadata = Maybe (HashMap Text Text)
a} :: SignUp) 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.
signUp_secretHash :: Lens.Lens' SignUp (Prelude.Maybe Prelude.Text)
signUp_secretHash :: Lens' SignUp (Maybe Text)
signUp_secretHash = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SignUp' {Maybe (Sensitive Text)
secretHash :: Maybe (Sensitive Text)
$sel:secretHash:SignUp' :: SignUp -> Maybe (Sensitive Text)
secretHash} -> Maybe (Sensitive Text)
secretHash) (\s :: SignUp
s@SignUp' {} Maybe (Sensitive Text)
a -> SignUp
s {$sel:secretHash:SignUp' :: Maybe (Sensitive Text)
secretHash = Maybe (Sensitive Text)
a} :: SignUp) 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

-- | An array of name-value pairs representing user attributes.
--
-- For custom attributes, you must prepend the @custom:@ prefix to the
-- attribute name.
signUp_userAttributes :: Lens.Lens' SignUp (Prelude.Maybe [AttributeType])
signUp_userAttributes :: Lens' SignUp (Maybe [AttributeType])
signUp_userAttributes = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SignUp' {Maybe [AttributeType]
userAttributes :: Maybe [AttributeType]
$sel:userAttributes:SignUp' :: SignUp -> Maybe [AttributeType]
userAttributes} -> Maybe [AttributeType]
userAttributes) (\s :: SignUp
s@SignUp' {} Maybe [AttributeType]
a -> SignUp
s {$sel:userAttributes:SignUp' :: Maybe [AttributeType]
userAttributes = Maybe [AttributeType]
a} :: SignUp) 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

-- | 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.
signUp_userContextData :: Lens.Lens' SignUp (Prelude.Maybe UserContextDataType)
signUp_userContextData :: Lens' SignUp (Maybe UserContextDataType)
signUp_userContextData = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SignUp' {Maybe UserContextDataType
userContextData :: Maybe UserContextDataType
$sel:userContextData:SignUp' :: SignUp -> Maybe UserContextDataType
userContextData} -> Maybe UserContextDataType
userContextData) (\s :: SignUp
s@SignUp' {} Maybe UserContextDataType
a -> SignUp
s {$sel:userContextData:SignUp' :: Maybe UserContextDataType
userContextData = Maybe UserContextDataType
a} :: SignUp)

-- | The validation data in the request to register a user.
signUp_validationData :: Lens.Lens' SignUp (Prelude.Maybe [AttributeType])
signUp_validationData :: Lens' SignUp (Maybe [AttributeType])
signUp_validationData = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SignUp' {Maybe [AttributeType]
validationData :: Maybe [AttributeType]
$sel:validationData:SignUp' :: SignUp -> Maybe [AttributeType]
validationData} -> Maybe [AttributeType]
validationData) (\s :: SignUp
s@SignUp' {} Maybe [AttributeType]
a -> SignUp
s {$sel:validationData:SignUp' :: Maybe [AttributeType]
validationData = Maybe [AttributeType]
a} :: SignUp) 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

-- | The ID of the client associated with the user pool.
signUp_clientId :: Lens.Lens' SignUp Prelude.Text
signUp_clientId :: Lens' SignUp Text
signUp_clientId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SignUp' {Sensitive Text
clientId :: Sensitive Text
$sel:clientId:SignUp' :: SignUp -> Sensitive Text
clientId} -> Sensitive Text
clientId) (\s :: SignUp
s@SignUp' {} Sensitive Text
a -> SignUp
s {$sel:clientId:SignUp' :: Sensitive Text
clientId = Sensitive Text
a} :: SignUp) 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 you want to register.
signUp_username :: Lens.Lens' SignUp Prelude.Text
signUp_username :: Lens' SignUp Text
signUp_username = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SignUp' {Sensitive Text
username :: Sensitive Text
$sel:username:SignUp' :: SignUp -> Sensitive Text
username} -> Sensitive Text
username) (\s :: SignUp
s@SignUp' {} Sensitive Text
a -> SignUp
s {$sel:username:SignUp' :: Sensitive Text
username = Sensitive Text
a} :: SignUp) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall a. Iso' (Sensitive a) a
Data._Sensitive

-- | The password of the user you want to register.
signUp_password :: Lens.Lens' SignUp Prelude.Text
signUp_password :: Lens' SignUp Text
signUp_password = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SignUp' {Sensitive Text
password :: Sensitive Text
$sel:password:SignUp' :: SignUp -> Sensitive Text
password} -> Sensitive Text
password) (\s :: SignUp
s@SignUp' {} Sensitive Text
a -> SignUp
s {$sel:password:SignUp' :: Sensitive Text
password = Sensitive Text
a} :: SignUp) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall a. Iso' (Sensitive a) a
Data._Sensitive

instance Core.AWSRequest SignUp where
  type AWSResponse SignUp = SignUpResponse
  request :: (Service -> Service) -> SignUp -> Request SignUp
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 SignUp
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse SignUp)))
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 -> Bool -> Text -> SignUpResponse
SignUpResponse'
            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))
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Either String a
Data..:> Key
"UserConfirmed")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Either String a
Data..:> Key
"UserSub")
      )

instance Prelude.Hashable SignUp where
  hashWithSalt :: Int -> SignUp -> Int
hashWithSalt Int
_salt SignUp' {Maybe [AttributeType]
Maybe (HashMap Text Text)
Maybe (Sensitive Text)
Maybe AnalyticsMetadataType
Maybe UserContextDataType
Sensitive Text
password :: Sensitive Text
username :: Sensitive Text
clientId :: Sensitive Text
validationData :: Maybe [AttributeType]
userContextData :: Maybe UserContextDataType
userAttributes :: Maybe [AttributeType]
secretHash :: Maybe (Sensitive Text)
clientMetadata :: Maybe (HashMap Text Text)
analyticsMetadata :: Maybe AnalyticsMetadataType
$sel:password:SignUp' :: SignUp -> Sensitive Text
$sel:username:SignUp' :: SignUp -> Sensitive Text
$sel:clientId:SignUp' :: SignUp -> Sensitive Text
$sel:validationData:SignUp' :: SignUp -> Maybe [AttributeType]
$sel:userContextData:SignUp' :: SignUp -> Maybe UserContextDataType
$sel:userAttributes:SignUp' :: SignUp -> Maybe [AttributeType]
$sel:secretHash:SignUp' :: SignUp -> Maybe (Sensitive Text)
$sel:clientMetadata:SignUp' :: SignUp -> Maybe (HashMap Text Text)
$sel:analyticsMetadata:SignUp' :: SignUp -> 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 [AttributeType]
userAttributes
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe UserContextDataType
userContextData
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [AttributeType]
validationData
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Sensitive Text
clientId
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Sensitive Text
username
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Sensitive Text
password

instance Prelude.NFData SignUp where
  rnf :: SignUp -> ()
rnf SignUp' {Maybe [AttributeType]
Maybe (HashMap Text Text)
Maybe (Sensitive Text)
Maybe AnalyticsMetadataType
Maybe UserContextDataType
Sensitive Text
password :: Sensitive Text
username :: Sensitive Text
clientId :: Sensitive Text
validationData :: Maybe [AttributeType]
userContextData :: Maybe UserContextDataType
userAttributes :: Maybe [AttributeType]
secretHash :: Maybe (Sensitive Text)
clientMetadata :: Maybe (HashMap Text Text)
analyticsMetadata :: Maybe AnalyticsMetadataType
$sel:password:SignUp' :: SignUp -> Sensitive Text
$sel:username:SignUp' :: SignUp -> Sensitive Text
$sel:clientId:SignUp' :: SignUp -> Sensitive Text
$sel:validationData:SignUp' :: SignUp -> Maybe [AttributeType]
$sel:userContextData:SignUp' :: SignUp -> Maybe UserContextDataType
$sel:userAttributes:SignUp' :: SignUp -> Maybe [AttributeType]
$sel:secretHash:SignUp' :: SignUp -> Maybe (Sensitive Text)
$sel:clientMetadata:SignUp' :: SignUp -> Maybe (HashMap Text Text)
$sel:analyticsMetadata:SignUp' :: SignUp -> 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 [AttributeType]
userAttributes
      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 Maybe [AttributeType]
validationData
      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
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Sensitive Text
password

instance Data.ToHeaders SignUp where
  toHeaders :: SignUp -> 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.SignUp" ::
                          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 SignUp where
  toJSON :: SignUp -> Value
toJSON SignUp' {Maybe [AttributeType]
Maybe (HashMap Text Text)
Maybe (Sensitive Text)
Maybe AnalyticsMetadataType
Maybe UserContextDataType
Sensitive Text
password :: Sensitive Text
username :: Sensitive Text
clientId :: Sensitive Text
validationData :: Maybe [AttributeType]
userContextData :: Maybe UserContextDataType
userAttributes :: Maybe [AttributeType]
secretHash :: Maybe (Sensitive Text)
clientMetadata :: Maybe (HashMap Text Text)
analyticsMetadata :: Maybe AnalyticsMetadataType
$sel:password:SignUp' :: SignUp -> Sensitive Text
$sel:username:SignUp' :: SignUp -> Sensitive Text
$sel:clientId:SignUp' :: SignUp -> Sensitive Text
$sel:validationData:SignUp' :: SignUp -> Maybe [AttributeType]
$sel:userContextData:SignUp' :: SignUp -> Maybe UserContextDataType
$sel:userAttributes:SignUp' :: SignUp -> Maybe [AttributeType]
$sel:secretHash:SignUp' :: SignUp -> Maybe (Sensitive Text)
$sel:clientMetadata:SignUp' :: SignUp -> Maybe (HashMap Text Text)
$sel:analyticsMetadata:SignUp' :: SignUp -> 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
"UserAttributes" 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 [AttributeType]
userAttributes,
            (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,
            (Key
"ValidationData" 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 [AttributeType]
validationData,
            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),
            forall a. a -> Maybe a
Prelude.Just (Key
"Password" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Sensitive Text
password)
          ]
      )

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

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

-- | The response from the server for a registration request.
--
-- /See:/ 'newSignUpResponse' smart constructor.
data SignUpResponse = SignUpResponse'
  { -- | The code delivery details returned by the server response to the user
    -- registration request.
    SignUpResponse -> Maybe CodeDeliveryDetailsType
codeDeliveryDetails :: Prelude.Maybe CodeDeliveryDetailsType,
    -- | The response's http status code.
    SignUpResponse -> Int
httpStatus :: Prelude.Int,
    -- | A response from the server indicating that a user registration has been
    -- confirmed.
    SignUpResponse -> Bool
userConfirmed :: Prelude.Bool,
    -- | The UUID of the authenticated user. This isn\'t the same as @username@.
    SignUpResponse -> Text
userSub :: Prelude.Text
  }
  deriving (SignUpResponse -> SignUpResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SignUpResponse -> SignUpResponse -> Bool
$c/= :: SignUpResponse -> SignUpResponse -> Bool
== :: SignUpResponse -> SignUpResponse -> Bool
$c== :: SignUpResponse -> SignUpResponse -> Bool
Prelude.Eq, ReadPrec [SignUpResponse]
ReadPrec SignUpResponse
Int -> ReadS SignUpResponse
ReadS [SignUpResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [SignUpResponse]
$creadListPrec :: ReadPrec [SignUpResponse]
readPrec :: ReadPrec SignUpResponse
$creadPrec :: ReadPrec SignUpResponse
readList :: ReadS [SignUpResponse]
$creadList :: ReadS [SignUpResponse]
readsPrec :: Int -> ReadS SignUpResponse
$creadsPrec :: Int -> ReadS SignUpResponse
Prelude.Read, Int -> SignUpResponse -> ShowS
[SignUpResponse] -> ShowS
SignUpResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SignUpResponse] -> ShowS
$cshowList :: [SignUpResponse] -> ShowS
show :: SignUpResponse -> String
$cshow :: SignUpResponse -> String
showsPrec :: Int -> SignUpResponse -> ShowS
$cshowsPrec :: Int -> SignUpResponse -> ShowS
Prelude.Show, forall x. Rep SignUpResponse x -> SignUpResponse
forall x. SignUpResponse -> Rep SignUpResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep SignUpResponse x -> SignUpResponse
$cfrom :: forall x. SignUpResponse -> Rep SignUpResponse x
Prelude.Generic)

-- |
-- Create a value of 'SignUpResponse' 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', 'signUpResponse_codeDeliveryDetails' - The code delivery details returned by the server response to the user
-- registration request.
--
-- 'httpStatus', 'signUpResponse_httpStatus' - The response's http status code.
--
-- 'userConfirmed', 'signUpResponse_userConfirmed' - A response from the server indicating that a user registration has been
-- confirmed.
--
-- 'userSub', 'signUpResponse_userSub' - The UUID of the authenticated user. This isn\'t the same as @username@.
newSignUpResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  -- | 'userConfirmed'
  Prelude.Bool ->
  -- | 'userSub'
  Prelude.Text ->
  SignUpResponse
newSignUpResponse :: Int -> Bool -> Text -> SignUpResponse
newSignUpResponse
  Int
pHttpStatus_
  Bool
pUserConfirmed_
  Text
pUserSub_ =
    SignUpResponse'
      { $sel:codeDeliveryDetails:SignUpResponse' :: Maybe CodeDeliveryDetailsType
codeDeliveryDetails =
          forall a. Maybe a
Prelude.Nothing,
        $sel:httpStatus:SignUpResponse' :: Int
httpStatus = Int
pHttpStatus_,
        $sel:userConfirmed:SignUpResponse' :: Bool
userConfirmed = Bool
pUserConfirmed_,
        $sel:userSub:SignUpResponse' :: Text
userSub = Text
pUserSub_
      }

-- | The code delivery details returned by the server response to the user
-- registration request.
signUpResponse_codeDeliveryDetails :: Lens.Lens' SignUpResponse (Prelude.Maybe CodeDeliveryDetailsType)
signUpResponse_codeDeliveryDetails :: Lens' SignUpResponse (Maybe CodeDeliveryDetailsType)
signUpResponse_codeDeliveryDetails = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SignUpResponse' {Maybe CodeDeliveryDetailsType
codeDeliveryDetails :: Maybe CodeDeliveryDetailsType
$sel:codeDeliveryDetails:SignUpResponse' :: SignUpResponse -> Maybe CodeDeliveryDetailsType
codeDeliveryDetails} -> Maybe CodeDeliveryDetailsType
codeDeliveryDetails) (\s :: SignUpResponse
s@SignUpResponse' {} Maybe CodeDeliveryDetailsType
a -> SignUpResponse
s {$sel:codeDeliveryDetails:SignUpResponse' :: Maybe CodeDeliveryDetailsType
codeDeliveryDetails = Maybe CodeDeliveryDetailsType
a} :: SignUpResponse)

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

-- | A response from the server indicating that a user registration has been
-- confirmed.
signUpResponse_userConfirmed :: Lens.Lens' SignUpResponse Prelude.Bool
signUpResponse_userConfirmed :: Lens' SignUpResponse Bool
signUpResponse_userConfirmed = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SignUpResponse' {Bool
userConfirmed :: Bool
$sel:userConfirmed:SignUpResponse' :: SignUpResponse -> Bool
userConfirmed} -> Bool
userConfirmed) (\s :: SignUpResponse
s@SignUpResponse' {} Bool
a -> SignUpResponse
s {$sel:userConfirmed:SignUpResponse' :: Bool
userConfirmed = Bool
a} :: SignUpResponse)

-- | The UUID of the authenticated user. This isn\'t the same as @username@.
signUpResponse_userSub :: Lens.Lens' SignUpResponse Prelude.Text
signUpResponse_userSub :: Lens' SignUpResponse Text
signUpResponse_userSub = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SignUpResponse' {Text
userSub :: Text
$sel:userSub:SignUpResponse' :: SignUpResponse -> Text
userSub} -> Text
userSub) (\s :: SignUpResponse
s@SignUpResponse' {} Text
a -> SignUpResponse
s {$sel:userSub:SignUpResponse' :: Text
userSub = Text
a} :: SignUpResponse)

instance Prelude.NFData SignUpResponse where
  rnf :: SignUpResponse -> ()
rnf SignUpResponse' {Bool
Int
Maybe CodeDeliveryDetailsType
Text
userSub :: Text
userConfirmed :: Bool
httpStatus :: Int
codeDeliveryDetails :: Maybe CodeDeliveryDetailsType
$sel:userSub:SignUpResponse' :: SignUpResponse -> Text
$sel:userConfirmed:SignUpResponse' :: SignUpResponse -> Bool
$sel:httpStatus:SignUpResponse' :: SignUpResponse -> Int
$sel:codeDeliveryDetails:SignUpResponse' :: SignUpResponse -> 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
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Bool
userConfirmed
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
userSub