{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE StrictData #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# 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.Types.AuthenticationResultType
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.CognitoIdentityProvider.Types.AuthenticationResultType where

import Amazonka.CognitoIdentityProvider.Types.NewDeviceMetadataType
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

-- | The authentication result.
--
-- /See:/ 'newAuthenticationResultType' smart constructor.
data AuthenticationResultType = AuthenticationResultType'
  { -- | A valid access token that Amazon Cognito issued to the user who you want
    -- to authenticate.
    AuthenticationResultType -> Maybe (Sensitive Text)
accessToken :: Prelude.Maybe (Data.Sensitive Prelude.Text),
    -- | The expiration period of the authentication result in seconds.
    AuthenticationResultType -> Maybe Int
expiresIn :: Prelude.Maybe Prelude.Int,
    -- | The ID token.
    AuthenticationResultType -> Maybe (Sensitive Text)
idToken :: Prelude.Maybe (Data.Sensitive Prelude.Text),
    -- | The new device metadata from an authentication result.
    AuthenticationResultType -> Maybe NewDeviceMetadataType
newDeviceMetadata' :: Prelude.Maybe NewDeviceMetadataType,
    -- | The refresh token.
    AuthenticationResultType -> Maybe (Sensitive Text)
refreshToken :: Prelude.Maybe (Data.Sensitive Prelude.Text),
    -- | The token type.
    AuthenticationResultType -> Maybe Text
tokenType :: Prelude.Maybe Prelude.Text
  }
  deriving (AuthenticationResultType -> AuthenticationResultType -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AuthenticationResultType -> AuthenticationResultType -> Bool
$c/= :: AuthenticationResultType -> AuthenticationResultType -> Bool
== :: AuthenticationResultType -> AuthenticationResultType -> Bool
$c== :: AuthenticationResultType -> AuthenticationResultType -> Bool
Prelude.Eq, Int -> AuthenticationResultType -> ShowS
[AuthenticationResultType] -> ShowS
AuthenticationResultType -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AuthenticationResultType] -> ShowS
$cshowList :: [AuthenticationResultType] -> ShowS
show :: AuthenticationResultType -> String
$cshow :: AuthenticationResultType -> String
showsPrec :: Int -> AuthenticationResultType -> ShowS
$cshowsPrec :: Int -> AuthenticationResultType -> ShowS
Prelude.Show, forall x.
Rep AuthenticationResultType x -> AuthenticationResultType
forall x.
AuthenticationResultType -> Rep AuthenticationResultType x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep AuthenticationResultType x -> AuthenticationResultType
$cfrom :: forall x.
AuthenticationResultType -> Rep AuthenticationResultType x
Prelude.Generic)

-- |
-- Create a value of 'AuthenticationResultType' 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:
--
-- 'accessToken', 'authenticationResultType_accessToken' - A valid access token that Amazon Cognito issued to the user who you want
-- to authenticate.
--
-- 'expiresIn', 'authenticationResultType_expiresIn' - The expiration period of the authentication result in seconds.
--
-- 'idToken', 'authenticationResultType_idToken' - The ID token.
--
-- 'newDeviceMetadata'', 'authenticationResultType_newDeviceMetadata' - The new device metadata from an authentication result.
--
-- 'refreshToken', 'authenticationResultType_refreshToken' - The refresh token.
--
-- 'tokenType', 'authenticationResultType_tokenType' - The token type.
newAuthenticationResultType ::
  AuthenticationResultType
newAuthenticationResultType :: AuthenticationResultType
newAuthenticationResultType =
  AuthenticationResultType'
    { $sel:accessToken:AuthenticationResultType' :: Maybe (Sensitive Text)
accessToken =
        forall a. Maybe a
Prelude.Nothing,
      $sel:expiresIn:AuthenticationResultType' :: Maybe Int
expiresIn = forall a. Maybe a
Prelude.Nothing,
      $sel:idToken:AuthenticationResultType' :: Maybe (Sensitive Text)
idToken = forall a. Maybe a
Prelude.Nothing,
      $sel:newDeviceMetadata':AuthenticationResultType' :: Maybe NewDeviceMetadataType
newDeviceMetadata' = forall a. Maybe a
Prelude.Nothing,
      $sel:refreshToken:AuthenticationResultType' :: Maybe (Sensitive Text)
refreshToken = forall a. Maybe a
Prelude.Nothing,
      $sel:tokenType:AuthenticationResultType' :: Maybe Text
tokenType = forall a. Maybe a
Prelude.Nothing
    }

-- | A valid access token that Amazon Cognito issued to the user who you want
-- to authenticate.
authenticationResultType_accessToken :: Lens.Lens' AuthenticationResultType (Prelude.Maybe Prelude.Text)
authenticationResultType_accessToken :: Lens' AuthenticationResultType (Maybe Text)
authenticationResultType_accessToken = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AuthenticationResultType' {Maybe (Sensitive Text)
accessToken :: Maybe (Sensitive Text)
$sel:accessToken:AuthenticationResultType' :: AuthenticationResultType -> Maybe (Sensitive Text)
accessToken} -> Maybe (Sensitive Text)
accessToken) (\s :: AuthenticationResultType
s@AuthenticationResultType' {} Maybe (Sensitive Text)
a -> AuthenticationResultType
s {$sel:accessToken:AuthenticationResultType' :: Maybe (Sensitive Text)
accessToken = Maybe (Sensitive Text)
a} :: AuthenticationResultType) 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

-- | The expiration period of the authentication result in seconds.
authenticationResultType_expiresIn :: Lens.Lens' AuthenticationResultType (Prelude.Maybe Prelude.Int)
authenticationResultType_expiresIn :: Lens' AuthenticationResultType (Maybe Int)
authenticationResultType_expiresIn = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AuthenticationResultType' {Maybe Int
expiresIn :: Maybe Int
$sel:expiresIn:AuthenticationResultType' :: AuthenticationResultType -> Maybe Int
expiresIn} -> Maybe Int
expiresIn) (\s :: AuthenticationResultType
s@AuthenticationResultType' {} Maybe Int
a -> AuthenticationResultType
s {$sel:expiresIn:AuthenticationResultType' :: Maybe Int
expiresIn = Maybe Int
a} :: AuthenticationResultType)

-- | The ID token.
authenticationResultType_idToken :: Lens.Lens' AuthenticationResultType (Prelude.Maybe Prelude.Text)
authenticationResultType_idToken :: Lens' AuthenticationResultType (Maybe Text)
authenticationResultType_idToken = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AuthenticationResultType' {Maybe (Sensitive Text)
idToken :: Maybe (Sensitive Text)
$sel:idToken:AuthenticationResultType' :: AuthenticationResultType -> Maybe (Sensitive Text)
idToken} -> Maybe (Sensitive Text)
idToken) (\s :: AuthenticationResultType
s@AuthenticationResultType' {} Maybe (Sensitive Text)
a -> AuthenticationResultType
s {$sel:idToken:AuthenticationResultType' :: Maybe (Sensitive Text)
idToken = Maybe (Sensitive Text)
a} :: AuthenticationResultType) 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

-- | The new device metadata from an authentication result.
authenticationResultType_newDeviceMetadata :: Lens.Lens' AuthenticationResultType (Prelude.Maybe NewDeviceMetadataType)
authenticationResultType_newDeviceMetadata :: Lens' AuthenticationResultType (Maybe NewDeviceMetadataType)
authenticationResultType_newDeviceMetadata = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AuthenticationResultType' {Maybe NewDeviceMetadataType
newDeviceMetadata' :: Maybe NewDeviceMetadataType
$sel:newDeviceMetadata':AuthenticationResultType' :: AuthenticationResultType -> Maybe NewDeviceMetadataType
newDeviceMetadata'} -> Maybe NewDeviceMetadataType
newDeviceMetadata') (\s :: AuthenticationResultType
s@AuthenticationResultType' {} Maybe NewDeviceMetadataType
a -> AuthenticationResultType
s {$sel:newDeviceMetadata':AuthenticationResultType' :: Maybe NewDeviceMetadataType
newDeviceMetadata' = Maybe NewDeviceMetadataType
a} :: AuthenticationResultType)

-- | The refresh token.
authenticationResultType_refreshToken :: Lens.Lens' AuthenticationResultType (Prelude.Maybe Prelude.Text)
authenticationResultType_refreshToken :: Lens' AuthenticationResultType (Maybe Text)
authenticationResultType_refreshToken = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AuthenticationResultType' {Maybe (Sensitive Text)
refreshToken :: Maybe (Sensitive Text)
$sel:refreshToken:AuthenticationResultType' :: AuthenticationResultType -> Maybe (Sensitive Text)
refreshToken} -> Maybe (Sensitive Text)
refreshToken) (\s :: AuthenticationResultType
s@AuthenticationResultType' {} Maybe (Sensitive Text)
a -> AuthenticationResultType
s {$sel:refreshToken:AuthenticationResultType' :: Maybe (Sensitive Text)
refreshToken = Maybe (Sensitive Text)
a} :: AuthenticationResultType) 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

-- | The token type.
authenticationResultType_tokenType :: Lens.Lens' AuthenticationResultType (Prelude.Maybe Prelude.Text)
authenticationResultType_tokenType :: Lens' AuthenticationResultType (Maybe Text)
authenticationResultType_tokenType = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AuthenticationResultType' {Maybe Text
tokenType :: Maybe Text
$sel:tokenType:AuthenticationResultType' :: AuthenticationResultType -> Maybe Text
tokenType} -> Maybe Text
tokenType) (\s :: AuthenticationResultType
s@AuthenticationResultType' {} Maybe Text
a -> AuthenticationResultType
s {$sel:tokenType:AuthenticationResultType' :: Maybe Text
tokenType = Maybe Text
a} :: AuthenticationResultType)

instance Data.FromJSON AuthenticationResultType where
  parseJSON :: Value -> Parser AuthenticationResultType
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"AuthenticationResultType"
      ( \Object
x ->
          Maybe (Sensitive Text)
-> Maybe Int
-> Maybe (Sensitive Text)
-> Maybe NewDeviceMetadataType
-> Maybe (Sensitive Text)
-> Maybe Text
-> AuthenticationResultType
AuthenticationResultType'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"AccessToken")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"ExpiresIn")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"IdToken")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"NewDeviceMetadata")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"RefreshToken")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"TokenType")
      )

instance Prelude.Hashable AuthenticationResultType where
  hashWithSalt :: Int -> AuthenticationResultType -> Int
hashWithSalt Int
_salt AuthenticationResultType' {Maybe Int
Maybe Text
Maybe (Sensitive Text)
Maybe NewDeviceMetadataType
tokenType :: Maybe Text
refreshToken :: Maybe (Sensitive Text)
newDeviceMetadata' :: Maybe NewDeviceMetadataType
idToken :: Maybe (Sensitive Text)
expiresIn :: Maybe Int
accessToken :: Maybe (Sensitive Text)
$sel:tokenType:AuthenticationResultType' :: AuthenticationResultType -> Maybe Text
$sel:refreshToken:AuthenticationResultType' :: AuthenticationResultType -> Maybe (Sensitive Text)
$sel:newDeviceMetadata':AuthenticationResultType' :: AuthenticationResultType -> Maybe NewDeviceMetadataType
$sel:idToken:AuthenticationResultType' :: AuthenticationResultType -> Maybe (Sensitive Text)
$sel:expiresIn:AuthenticationResultType' :: AuthenticationResultType -> Maybe Int
$sel:accessToken:AuthenticationResultType' :: AuthenticationResultType -> Maybe (Sensitive Text)
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe (Sensitive Text)
accessToken
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Int
expiresIn
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe (Sensitive Text)
idToken
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe NewDeviceMetadataType
newDeviceMetadata'
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe (Sensitive Text)
refreshToken
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
tokenType

instance Prelude.NFData AuthenticationResultType where
  rnf :: AuthenticationResultType -> ()
rnf AuthenticationResultType' {Maybe Int
Maybe Text
Maybe (Sensitive Text)
Maybe NewDeviceMetadataType
tokenType :: Maybe Text
refreshToken :: Maybe (Sensitive Text)
newDeviceMetadata' :: Maybe NewDeviceMetadataType
idToken :: Maybe (Sensitive Text)
expiresIn :: Maybe Int
accessToken :: Maybe (Sensitive Text)
$sel:tokenType:AuthenticationResultType' :: AuthenticationResultType -> Maybe Text
$sel:refreshToken:AuthenticationResultType' :: AuthenticationResultType -> Maybe (Sensitive Text)
$sel:newDeviceMetadata':AuthenticationResultType' :: AuthenticationResultType -> Maybe NewDeviceMetadataType
$sel:idToken:AuthenticationResultType' :: AuthenticationResultType -> Maybe (Sensitive Text)
$sel:expiresIn:AuthenticationResultType' :: AuthenticationResultType -> Maybe Int
$sel:accessToken:AuthenticationResultType' :: AuthenticationResultType -> Maybe (Sensitive Text)
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe (Sensitive Text)
accessToken
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Int
expiresIn
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe (Sensitive Text)
idToken
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe NewDeviceMetadataType
newDeviceMetadata'
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe (Sensitive Text)
refreshToken
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
tokenType